Skip to content

Commit f03705d

Browse files
changed ints to strings and updated readme
1 parent 62aab17 commit f03705d

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ The app uses the go-git library and git repos (of your choice) that you have clo
1111
For example,
1212
to create a steady state for the garbage collector, you could read the repo for Ruby on Rails into memory 50 times with a 2 second pause in between each read.
1313

14-
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/rails", "repeat":50, "pause":2}' -X POST http://localhost:8000/git_repo
14+
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/rails", "repeat":"50", "pause":"2"}' -X POST http://localhost:8000/git_repo
1515

1616
Then, if you want to, create a transitory spike in memory, you could open another terminal window and read youtube-dl into memory once.
1717

18-
<p>curl -H 'Content-Type: application/json' -d '{"path":"/path/to/youtube-dl", "repeat":1, "pause":1}' -X POST http://localhost:8000/git_repo</p>
18+
<p>curl -H 'Content-Type: application/json' -d '{"path":"/path/to/youtube-dl", "repeat":"1", "pause":"1"}' -X POST http://localhost:8000/git_repo</p>
1919

2020
## Understanding GOMEMLIMIT and GOGC
2121
You can find tips for setting GOGC and GOMEMLIMIT at Go's garbage collection guide https://tip.golang.org/doc/gc-guide
@@ -35,3 +35,19 @@ curl http://localhost:8000/print_all_metrics (from runtime/Metrics package)
3535
curl http://localhost:8000/print_some_metrics (from runtime/Metrics package)
3636

3737
the browser app uses Go's expvar package
38+
39+
## Reading the Live Graph
40+
There are two real-time graphs. On the left, there is a bar chart of the current gc cycle. On the right, there is a real-time line graph over time.
41+
42+
https://imgur.com/a/bxggcwk
43+
44+
In this example, you can see there was a heap spike at approximately 3:16:45. In the bar chart on the left, it says the current values (NextGC is 801540296 bytes etc), which is also the reading of the NextGC on the right hand line graph (see above the graph) at its far right side (i.e the real time line graph moves from right to left).
45+
46+
This example was run using ruby on rails to establish a steady state
47+
48+
curl -H 'Content-Type: application/json' -d '{"path":"/Users/mm/rails", "repeat":"50", "pause":"2"}' -X POST http://localhost:8000/git_repo
49+
50+
and then using the Rust repository to create a heap spike
51+
52+
curl -H 'Content-Type: application/json' -d '{"path":"/Users/mm/rust", "repeat":"3", "pause":"1"}' -X POST http://localhost:8000/git_repo
53+

gitrepo.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66
"mime"
77
"net/http"
8+
"strconv"
89
"time"
910

1011
git "github.com/go-git/go-git/v5"
@@ -15,8 +16,8 @@ func GitRepo(w http.ResponseWriter, req *http.Request) {
1516

1617
type GitRepo struct {
1718
Path string `json:"path"`
18-
Repeat int `json:"repeat"`
19-
Pause int `json:"pause`
19+
Repeat string `json:"repeat"`
20+
Pause string `json:"pause`
2021
}
2122
type ResponseId struct {
2223
Id int `json:"id"`
@@ -46,8 +47,9 @@ func GitRepo(w http.ResponseWriter, req *http.Request) {
4647
var execTime time.Duration
4748

4849
startTime := time.Now()
49-
50-
_, _, _ = getLog(gr.Path, gr.Repeat, gr.Pause)
50+
repeat, err := strconv.Atoi(gr.Repeat)
51+
pause, err := strconv.Atoi(gr.Pause)
52+
_, _, _ = getLog(gr.Path, repeat, pause)
5153

5254
stopTime := time.Now()
5355
executionTime := stopTime.Sub(startTime)
@@ -62,8 +64,8 @@ func GitRepo(w http.ResponseWriter, req *http.Request) {
6264

6365
res := response{
6466
Path: gr.Path,
65-
Repeat: gr.Repeat,
66-
Pause: gr.Pause,
67+
Repeat: repeat,
68+
Pause: pause,
6769
ExecutionTime: execTime,
6870
}
6971

0 commit comments

Comments
 (0)