demo/digitalocean: better benchmark

This commit is contained in:
Ryan Uber 2015-09-26 09:39:19 -07:00
parent 5b99887dfb
commit 1a4934f390

View file

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"os/exec"
"time" "time"
"github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/api"
@ -16,10 +17,16 @@ func main() {
} }
total := 4000 total := 4000
running := 0 isRunning := false
start := time.Now() start := time.Now()
allocClient := client.Allocations() allocClient := client.Allocations()
cmd := exec.Command("nomad", "run", "bench.nomad")
if err := cmd.Run(); err != nil {
fmt.Println("nomad run failed: " + err.Error())
return
}
fmt.Printf("benchmarking %d allocations\n", total) fmt.Printf("benchmarking %d allocations\n", total)
for i := 0; ; i++ { for i := 0; ; i++ {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
@ -33,10 +40,12 @@ func main() {
} }
now := time.Now() now := time.Now()
running := 0
for _, alloc := range allocs { for _, alloc := range allocs {
if alloc.ClientStatus == structs.AllocClientStatusRunning { if alloc.ClientStatus == structs.AllocClientStatusRunning {
if running == 0 { if !isRunning {
fmt.Println("time to first running: %s", now.Sub(start)) fmt.Printf("time to first running: %s\n", now.Sub(start))
isRunning = true
} }
running++ running++
} }