88 "bytes"
99 "context"
1010 "encoding/json"
11+ "errors"
1112 "fmt"
1213 "io"
1314 "math"
@@ -190,7 +191,7 @@ func benchMain(args []string, params benchmarkCommandParams, w io.Writer, r benc
190191 if err != nil {
191192 return err
192193 } else if len (result ) == 0 && params .fail {
193- return fmt . Errorf ("undefined result" )
194+ return errors . New ("undefined result" )
194195 }
195196 return nil
196197 }
@@ -207,7 +208,7 @@ func benchMain(args []string, params benchmarkCommandParams, w io.Writer, r benc
207208 if err != nil {
208209 return err
209210 } else if len (result .Queries ) == 0 && params .fail {
210- return fmt . Errorf ("undefined result" )
211+ return errors . New ("undefined result" )
211212 }
212213 return nil
213214 }
@@ -307,7 +308,7 @@ func benchE2E(ctx context.Context, args []string, params benchmarkCommandParams,
307308 // We fix the issue here by binding port 0; this will result in the OS
308309 // allocating us an open port.
309310 rtParams := runtime.Params {
310- Addrs : & []string {fmt . Sprintf ( "%s :0", host ) },
311+ Addrs : & []string {host + " :0" },
311312 Paths : paths ,
312313 Logger : logger ,
313314 BundleMode : params .bundlePaths .isFlagSet (),
@@ -365,7 +366,7 @@ func benchE2E(ctx context.Context, args []string, params benchmarkCommandParams,
365366 }
366367 // Check for port still being unbound after retry loop.
367368 if port == 0 {
368- return fmt . Errorf ("unable to bind a port for bench testing" )
369+ return errors . New ("unable to bind a port for bench testing" )
369370 }
370371
371372 query , err := readQuery (params , args )
@@ -399,7 +400,7 @@ func benchE2E(ctx context.Context, args []string, params benchmarkCommandParams,
399400 } else {
400401 _ , err := ast .ParseBody (query )
401402 if err != nil {
402- return fmt . Errorf ("error occurred while parsing query" )
403+ return errors . New ("error occurred while parsing query" )
403404 }
404405
405406 if strings .HasPrefix (query , "data." ) {
@@ -536,7 +537,7 @@ func e2eQuery(params benchmarkCommandParams, url string, input map[string]interf
536537 }
537538
538539 if result .Result == nil && params .fail {
539- return nil , fmt . Errorf ("undefined result" )
540+ return nil , errors . New ("undefined result" )
540541 }
541542
542543 return result .Metrics , nil
@@ -549,31 +550,31 @@ func e2eQuery(params benchmarkCommandParams, url string, input map[string]interf
549550
550551 if params .fail {
551552 if result .Result == nil {
552- return nil , fmt . Errorf ("undefined result" )
553+ return nil , errors . New ("undefined result" )
553554 }
554555
555556 i := * result .Result
556557
557558 peResult , ok := i .(map [string ]interface {})
558559 if ! ok {
559- return nil , fmt . Errorf ("invalid result for compile response" )
560+ return nil , errors . New ("invalid result for compile response" )
560561 }
561562
562563 if len (peResult ) == 0 {
563- return nil , fmt . Errorf ("undefined result" )
564+ return nil , errors . New ("undefined result" )
564565 }
565566
566567 if val , ok := peResult ["queries" ]; ok {
567568 queries , ok := val .([]interface {})
568569 if ! ok {
569- return nil , fmt . Errorf ("invalid result for output of partial evaluation" )
570+ return nil , errors . New ("invalid result for output of partial evaluation" )
570571 }
571572
572573 if len (queries ) == 0 {
573- return nil , fmt . Errorf ("undefined result" )
574+ return nil , errors . New ("undefined result" )
574575 }
575576 } else {
576- return nil , fmt . Errorf ("invalid result for output of partial evaluation" )
577+ return nil , errors . New ("invalid result for output of partial evaluation" )
577578 }
578579 }
579580
@@ -606,14 +607,14 @@ func renderBenchmarkResult(params benchmarkCommandParams, br testing.BenchmarkRe
606607 fmt .Fprintf (w , "\n " )
607608 default :
608609 data := [][]string {
609- {"samples" , fmt . Sprintf ( "%d" , br .N )},
610+ {"samples" , strconv . Itoa ( br .N )},
610611 {"ns/op" , prettyFormatFloat (float64 (br .T .Nanoseconds ()) / float64 (br .N ))},
611612 }
612613 if params .benchMem {
613614 data = append (data , []string {
614- "B/op" , fmt . Sprintf ( "%d" , br .AllocedBytesPerOp ()),
615+ "B/op" , strconv . FormatInt ( br .AllocedBytesPerOp (), 10 ),
615616 }, []string {
616- "allocs/op" , fmt . Sprintf ( "%d" , br .AllocsPerOp ()),
617+ "allocs/op" , strconv . FormatInt ( br .AllocsPerOp (), 10 ),
617618 })
618619 }
619620
0 commit comments