-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
106 lines (66 loc) · 2.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package main
import (
_ "net/http/pprof"
"pkvstore/api/storageserver"
)
// func main() {
// // Start profiling server
// // go func() {
// // log.Println(http.ListenAndServe("localhost:6060", nil))
// // }()
// store := store.NewStore()
// store.Put("name1", "akash")
// store.Put("address1", "dhanmandi")
// store.Put("name2", "bkash")
// store.Put("address2", "dhanmandi")
// store.Put("name3", "dkash")
// store.Put("address3", "dhanmandi")
// store.Put("name", "ckash")
// store.Delete("name")
// newUser(store, 10)
// fmt.Println("name1: ", store.Get("name1")) // Output: one
// fmt.Println("name2: ", store.Get("name2")) // Output: one
// fmt.Println("name3: ", store.Get("name3")) // Output: one
// fmt.Println("name: ", store.Get("name")) // Output: one
// }
// func generateAndPutData(current int, lsm *store.Store, wg *sync.WaitGroup) {
// defer wg.Done()
// var key string
// for i := int64(0); i < 100; i++ {
// randomNumber := rand.Int63n(1<<63 - 1)
// key = strconv.FormatInt(randomNumber, 10)
// value := strconv.FormatInt(randomNumber, 10)
// lsm.Put(key, value)
// // fmt.Println("get:", lsm.Get(key))
// }
// fmt.Printf("Goroutine %d completed\n", current)
// }
// func newUser(store *store.Store, i int) {
// start := time.Now()
// numGoroutines := 100
// var wg sync.WaitGroup
// wg.Add(numGoroutines)
// for j := 0; j < numGoroutines; j++ {
// go generateAndPutData(j, store, &wg)
// time.Sleep(3 * time.Second)
// }
// wg.Wait()
// end := time.Now()
// duration := end.Sub(start)
// fmt.Println("duration: ", i, duration.Minutes())
// }
func main() {
storageserver.NewStorageServer()
// time.Sleep(time.Second * 10)
// client := storageclient.NewStorageClient()
// client.Put("name1", "akash")
// client.Put("address1", "dhanmandi")
// client.Put("name2", "bkash")
// client.Put("address2", "dhanmandi")
// client.Put("name3", "dkash")
// client.Put("address3", "dhanmandi")
// client.Put("name", "ckash")
// fmt.Println(client.Get("name1"))
// fmt.Println(client.Delete("name1"))
// fmt.Println(client.Get("name1"))
}