Skip to content

Instantly share code, notes, and snippets.

@arya
Last active December 13, 2016 19:09
Show Gist options
  • Save arya/7e23e8654e87a6e80608ade43ee31041 to your computer and use it in GitHub Desktop.
Save arya/7e23e8654e87a6e80608ade43ee31041 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os/exec"
"syscall"
"time"
)
func main() {
var s []*[1024 * 1024]byte
for i := 0; ; i++ {
start := time.Now()
for j := 0; j < 100; j++ {
cmd := exec.Command("echo")
cmd.SysProcAttr = &syscall.SysProcAttr{}
cmd.SysProcAttr.Cloneflags = syscall.CLONE_VFORK
cmd.Run()
}
fmt.Printf("%dGB: %s\n", i, time.Now().Sub(start)/time.Duration(100))
if i == 3 {
break
}
for j := 0; j < 1024; j++ {
s = append(s, new([1024 * 1024]byte))
cmd := exec.Command("echo")
cmd.SysProcAttr = &syscall.SysProcAttr{}
cmd.SysProcAttr.Cloneflags = syscall.CLONE_VFORK
cmd.Run()
}
}
}
package main
import (
"fmt"
"os/exec"
"time"
)
func main() {
var s []*[1024 * 1024]byte
for i := 0; ; i++ {
start := time.Now()
for j := 0; j < 100; j++ {
exec.Command("echo").Run()
}
fmt.Printf("%dGB: %s\n", i, time.Now().Sub(start)/time.Duration(100))
if i == 3 {
break
}
for j := 0; j < 1024; j++ {
s = append(s, new([1024 * 1024]byte))
exec.Command("echo").Run()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment