• Stars
    star
    300
  • Rank 133,703 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quick and easy performance analyzer library for golang

Nitro

Quick and easy performance analyzer library for golang.

Overview

Nitro is a quick and easy performance analyzer library for golang. It is useful for comparing A/B against different drafts of functions or different functions.

Implementing Nitro

Using Nitro is simple. First use go get to install the latest version of the library.

$ go get github.com/spf13/nitro

Next include nitro in your application.

import "github.com/spf13/nitro"

Somewhere near the beginning of your application (or where you want to begin profiling) call

timer := nitro.Initialize()

Then throughout your application wherever a major division of work is call

timer.Step("name of step")

Flags

Nitro automatically adds a flag to your application. If you aren't already using flags in your application the following code is an example of how you may use flags. Make sure to import "flag".

func main() {
    flag.Parse()
}

Bring your own flags implementation

If you are using your own flag system or a commander like cobra you may want to enable Nitro on your own. To enable Nitro without using the default flags, simply set the package variable '&nitro.AnalysisOn' to true. The following example uses a flagset:

Flags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")

var Timer *nitro.B

func init() {
    Timer = nitro.Initalize()
}

func TrackMe() {
    // a bunch of code here
    Timer.Step("important function to track")
}

func TrackAnother() {
    // more code here
    Timer.Step("another function to track")
}

Usage

Once the library is implemented throughout your application simply run your application and pass the "--stepAnalysis" flag to it. It does not need to be built to run, but can be called from go run or the binary form.

$ go run ./my_application --stepAnalysis

Example output

The following output comes from the hugo static site generator library. Nitro was built as a component of hugo and was extracted into it's own library.

$ ./main -p spf13 -b http://localhost -d --stepAnalysis

initialize & template prep:
    4.664481ms (5.887625ms)	        0.43 MB 	4583 Allocs
import pages:
    65.196788ms (71.107809ms)	   17.13 MB 	70151 Allocs
build indexes:
    1.823434ms (72.960713ms)	    0.12 MB 	3720 Allocs
render and write indexes:
    212.06721ms (285.057592ms)	   65.72 MB 	362557 Allocs
render and write lists:
    17.796945ms (302.87847ms)	    7.76 MB 	33122 Allocs
render pages:
    50.092756ms (352.998539ms)	   11.27 MB 	139898 Allocs
render shortcodes:
    11.34692ms (364.386939ms)	    6.24 MB 	21260 Allocs
render and write homepage:
    4.075194ms (368.497883ms)	    0.84 MB 	3906 Allocs
write pages:
    8.73933ms (377.263888ms)	    0.11 MB 	1672 Allocs

Release Notes

  • 0.5.0 Oct 1, 2013
    • Now supporting non flag based enabling
  • 0.4.0 June 19, 2013
    • Implement first draft

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contributors

Names in no particular order:

License

nitro is released under the Apache 2.0 license. See LICENSE.txt

More Repositories

1

cobra

A Commander for modern Go CLI interactions
Go
35,876
star
2

viper

Go configuration with fangs
Go
25,815
star
3

spf13-vim

The ultimate vim distribution
Vim Script
15,549
star
4

afero

A FileSystem Abstraction System for Go
Go
5,660
star
5

cast

safe and easy casting from one type to another in Go
Go
3,073
star
6

cobra-cli

Cobra CLI tool to generate applications and commands
Go
579
star
7

hyde

Port of Mdo's excellent theme to Hugo
CSS
533
star
8

jwalterweatherman

So you always leave a note
Go
261
star
9

PIV

PHP Integration environment for Vim
Vim Script
251
star
10

spf13.com

Hugo Based website of Steve Francia
CSS
143
star
11

dagobah

dagobah is an awesome RSS feed aggregator & reader written in Go inspired by planet
Go
135
star
12

kaiju

Open source discussion server
JavaScript
113
star
13

herring-cove

Port of arnp's excellent theme to Hugo
CSS
43
star
14

vim-colors

Collection of color schemes for VIM
Vim Script
40
star
15

mongoProducts

Sample data for Mongo Product Presentation
37
star
16

tri

Todo CLI app
Go
32
star
17

dotfiles

spf13's dotfiles
Shell
27
star
18

firstGoApp-Planet

Built for OSCON2014 .. Each step is in it's own branch
Go
20
star
19

Vogon

A MongoDB PHP based blog
JavaScript
16
star
20

Milieu

Location based check in application powered by MongoDB written in Ruby
Ruby
13
star
21

cobra.dev

Cobra website
HTML
7
star
22

relativeTime

Golang relative date formatting (1 day ago, in 2 weeks), etc.
7
star
23

stevefrancia.com

Homepage Website for SteveFrancia.com
HTML
6
star
24

wp_GitHub_Code_Viewer

Plugin for Wordpress to insert file from github into a blog post
PHP
5
star
25

spf13

5
star
26

spf13.github.com

Git Hub Page for spf13
4
star
27

vim-gocode

Vim Plugin of nsf/gocode for use with Vundle/Pathogen
Vim Script
3
star
28

vimbrant

Harnessing the power of vim to turn source into highlighted html
3
star
29

One-More-For-The-Road

A Skeleton App for Sinatra using MongoDB
JavaScript
3
star
30

instant

Instant theme for Hugo (derived from Black Tie Instant)
HTML
2
star
31

Autostamp

Auto update the time and version stamp in the header for VIM
Vim Script
1
star
32

YourFirstRubyMongoDBApp

Skeleton for your first ruby MongoDB app to go along with my workshop
Ruby
1
star