1
2
3
4
5 package main
6
7
8
9
10
11
12
13 import "C"
14
15 import (
16 "fmt"
17 "os"
18 "os/user"
19 "runtime"
20 "sync"
21 )
22
23 func main() {
24 u, err := user.Current()
25 if err != nil {
26 fmt.Fprintln(os.Stderr, err)
27
28 os.Exit(0)
29 }
30
31 var wg sync.WaitGroup
32 for i := 0; i < 20; i++ {
33 wg.Add(2)
34 go func() {
35 defer wg.Done()
36 for i := 0; i < 1000; i++ {
37 user.Lookup(u.Username)
38 runtime.Gosched()
39 }
40 }()
41 go func() {
42 defer wg.Done()
43 for i := 0; i < 1000; i++ {
44 p := C.malloc(C.size_t(len(u.Username) + 1))
45 runtime.Gosched()
46 C.free(p)
47 }
48 }()
49 }
50 wg.Wait()
51 }
52
View as plain text