Skip to content

Commit 5f67c68

Browse files
initial commit, main and readme
0 parents  commit 5f67c68

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## What is it
2+
The GC Knobs client allows you to make bulk requests to GC Knobs
3+
4+
## How to use
5+
clone and start https://github.com/MikeMitchellWebDev/gc_knobs.git
6+
7+
clone and run gc_knobs_client like this
8+
9+
./gc_knobs_client -g 200 -s 1 -r 10 -p "/Users/mm/rails"
10+
11+
This commmand will read a locally cloned copy of ruby on rails into memory
12+
2000 times (spawning 200 go routines, each making the request 10 times with a sleep of 1 second between each request)
13+
14+
15+
-g is the number of goroutines
16+
-s is the sleep duration between requests
17+
-r is the number of repeats
18+
-p is the path to the locally cloned repository
19+
20+
You don't need the gc_knobs_client to use gc_knobs. You can also use gc_knobs with curl
21+
22+
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/rails", "repeat":"50", "sleep":"2"}' -X POST http://localhost:8000/git_repo
23+

gc_knobs_client

7.02 MB
Binary file not shown.

main.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"encoding/json"
6+
"flag"
7+
"fmt"
8+
"net/http"
9+
"strconv"
10+
"sync"
11+
"time"
12+
)
13+
14+
var (
15+
path = flag.String("p", "", "string")
16+
goroutines = flag.Int("g", 4, "int")
17+
sleep = flag.Int("s", 1, "int")
18+
repeats = flag.Int("r", 1, "int")
19+
)
20+
21+
func main() {
22+
flag.Parse()
23+
24+
repeat_requests := strconv.Itoa(*repeats)
25+
sleep_between_requests := strconv.Itoa(*sleep)
26+
values := map[string]string{"repeat": repeat_requests, "sleep": sleep_between_requests, "path": *path}
27+
jsonValue, err := json.Marshal(values)
28+
if err != nil {
29+
fmt.Println(err)
30+
}
31+
wg1 := &sync.WaitGroup{}
32+
wg1.Add(*goroutines)
33+
startTime := time.Now()
34+
for i := 0; i < *goroutines; i++ {
35+
go func() {
36+
_, err := http.Post("http://localhost:8000/git_repo", "application/json", bytes.NewBuffer(jsonValue))
37+
if err != nil {
38+
fmt.Println(err)
39+
}
40+
41+
wg1.Done()
42+
}()
43+
44+
}
45+
wg1.Wait()
46+
stopTime := time.Now()
47+
executionTime := stopTime.Sub(startTime)
48+
fmt.Println("execution time", executionTime)
49+
}

0 commit comments

Comments
 (0)