From e9970b68f76c97983176f289e2a74ec5be3ba963 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Sat, 26 Sep 2015 09:39:19 -0700 Subject: [PATCH] demo/digitalocean: better benchmark --- demo/digitalocean/app/main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/demo/digitalocean/app/main.go b/demo/digitalocean/app/main.go index 97c1c8c21..c5b0145d3 100644 --- a/demo/digitalocean/app/main.go +++ b/demo/digitalocean/app/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os/exec" "time" "github.com/hashicorp/nomad/api" @@ -16,10 +17,16 @@ func main() { } total := 4000 - running := 0 + isRunning := false start := time.Now() 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) for i := 0; ; i++ { time.Sleep(100 * time.Millisecond) @@ -33,10 +40,12 @@ func main() { } now := time.Now() + running := 0 for _, alloc := range allocs { if alloc.ClientStatus == structs.AllocClientStatusRunning { - if running == 0 { - fmt.Println("time to first running: %s", now.Sub(start)) + if !isRunning { + fmt.Printf("time to first running: %s\n", now.Sub(start)) + isRunning = true } running++ }