demo/digitalocean: better benchmark

This commit is contained in:
Ryan Uber 2015-09-26 09:39:19 -07:00
parent 5b99887dfb
commit 1a4934f390
1 changed files with 12 additions and 3 deletions

View File

@ -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++
}