Skip to content

Commit

Permalink
rename to kagenui
Browse files Browse the repository at this point in the history
  • Loading branch information
netmarkjp committed Nov 9, 2014
1 parent e7d4baf commit 2014430
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
miniprofiler
kagenui
============

miniprofiler for golang
kagenui is profiler for golang

Good for use with web application.

Usage
============

```
go get github.com/netmarkjp/miniprofiler
go get github.com/netmarkjp/kagenui
```


```
import "github.com/netmarkjp/miniprofiler"
import "github.com/netmarkjp/kagenui"
func someHandler(w http.ResponseWriter, r *http.Request) {
mp := miniprofiler.Begin("someHandler")
mp := kagenui.Begin("someHandler")
defer mp.End()
...
Expand All @@ -30,9 +30,9 @@ func someHandler(w http.ResponseWriter, r *http.Request) {
}
func profileHandler(w http.ResponseWriter, r *http.Request) {
miniprofiler.Analyze(w)
// miniprofiler.Dump(w)
miniprofiler.Flush()
kagenui.Analyze(w)
// kagenui.Dump(w)
kagenui.Flush()
}
```

Expand Down Expand Up @@ -86,9 +86,9 @@ Customize
## Enable/Disable

```
miniprofiler.Enable()
kagenui.Enable()
```

```
miniprofiler.Disable()
kagenui.Disable()
```
26 changes: 13 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package miniprofiler
package kagenui

import (
"fmt"
Expand All @@ -10,25 +10,25 @@ import (
)

var (
mp *MiniProfiler
mp *Kagenui
enabled bool
condition func() bool
)

type MiniProfilerData struct {
type KagenuiData struct {
description string
steps map[string]int64
lastStep time.Time
memos []string
}

type MiniProfiler struct {
profiles []*MiniProfilerData
type Kagenui struct {
profiles []*KagenuiData
}

func init() {
mp = new(MiniProfiler)
mp.profiles = make([]*MiniProfilerData, 0)
mp = new(Kagenui)
mp.profiles = make([]*KagenuiData, 0)
enabled = true
condition = func() bool { return true }
}
Expand All @@ -45,14 +45,14 @@ func SetCondition(c func() bool) {
condition = c
}

func Begin(description string) *MiniProfilerData {
func Begin(description string) *KagenuiData {
if !enabled {
return nil
}
if !condition() {
return nil
}
return &MiniProfilerData{description, make(map[string]int64, 0), time.Now(), make([]string, 0)}
return &KagenuiData{description, make(map[string]int64, 0), time.Now(), make([]string, 0)}
}

func Dump(writer io.Writer) {
Expand All @@ -76,7 +76,7 @@ func Dump(writer io.Writer) {
}

func Flush() {
mp.profiles = make([]*MiniProfilerData, 0)
mp.profiles = make([]*KagenuiData, 0)
}

type Measure struct {
Expand Down Expand Up @@ -244,7 +244,7 @@ func Analyze(writer io.Writer) {
}
}

func (mpd *MiniProfilerData) Step(tag string) {
func (mpd *KagenuiData) Step(tag string) {
if !enabled {
return
}
Expand All @@ -258,7 +258,7 @@ func (mpd *MiniProfilerData) Step(tag string) {
mpd.lastStep = now
}

func (mpd *MiniProfilerData) Memo(memo string) {
func (mpd *KagenuiData) Memo(memo string) {
if !enabled {
return
}
Expand All @@ -280,7 +280,7 @@ func memoFilter(memo string) string {
return memo
}

func (mpd *MiniProfilerData) End() {
func (mpd *KagenuiData) End() {
if !enabled {
return
}
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package miniprofiler
package kagenui

import (
"math/rand"
Expand Down

0 comments on commit 2014430

Please sign in to comment.