@@ -6,15 +6,11 @@ package testing
6
6
7
7
import (
8
8
"context"
9
- "crypto/rand"
10
- "encoding/hex"
11
- "encoding/json"
12
9
"flag"
13
10
"fmt"
14
11
"io"
15
12
"math"
16
13
"os"
17
- "path/filepath"
18
14
"runtime"
19
15
"slices"
20
16
"strconv"
@@ -469,8 +465,6 @@ func (b *B) loopSlowPath() bool {
469
465
if b .loop .n < uint64 (b .benchTime .n ) {
470
466
b .loop .n = uint64 (b .benchTime .n )
471
467
b .loop .i ++
472
- b .ResetTimer ()
473
- b .StartTimer ()
474
468
return true
475
469
}
476
470
b .StopTimer ()
@@ -793,79 +787,6 @@ func (s *benchState) processBench(b *B) {
793
787
continue
794
788
}
795
789
results := r .String ()
796
-
797
- // ############################################################################################
798
- // START CODSPEED
799
- type RawResults struct {
800
- BenchmarkName string `json:"benchmark_name"`
801
- Pid int `json:"pid"`
802
- CodspeedTimePerRoundNs []time.Duration `json:"codspeed_time_per_round_ns"`
803
- CodspeedItersPerRound []int64 `json:"codspeed_iters_per_round"`
804
- }
805
-
806
- // Build custom bench name with :: separator
807
- var nameParts []string
808
- current := & b .common
809
- for current .parent != nil {
810
- // Extract the sub-benchmark part by removing parent prefix
811
- parentName := current .parent .name
812
- if strings .HasPrefix (current .name , parentName + "/" ) {
813
- subName := strings .TrimPrefix (current .name , parentName + "/" )
814
- nameParts = append ([]string {subName }, nameParts ... )
815
- } else {
816
- nameParts = append ([]string {current .name }, nameParts ... )
817
- }
818
-
819
- if current .parent .name == "Main" {
820
- break
821
- }
822
- current = current .parent
823
- }
824
- customBenchName := strings .Join (nameParts , "::" )
825
-
826
- rawResults := RawResults {
827
- BenchmarkName : customBenchName ,
828
- Pid : os .Getpid (),
829
- CodspeedTimePerRoundNs : r .CodspeedTimePerRoundNs ,
830
- CodspeedItersPerRound : r .CodspeedItersPerRound ,
831
- }
832
-
833
- codspeedProfileFolder := os .Getenv ("CODSPEED_PROFILE_FOLDER" )
834
- if codspeedProfileFolder == "" {
835
- panic ("CODSPEED_PROFILE_FOLDER environment variable is not set" )
836
- }
837
- if err := os .MkdirAll (filepath .Join (codspeedProfileFolder , "raw_results" ), 0755 ); err != nil {
838
- fmt .Fprintf (os .Stderr , "failed to create raw results directory: %v\n " , err )
839
- continue
840
- }
841
- // Generate random filename to avoid any overwrites
842
- randomBytes := make ([]byte , 16 )
843
- if _ , err := rand .Read (randomBytes ); err != nil {
844
- fmt .Fprintf (os .Stderr , "failed to generate random filename: %v\n " , err )
845
- continue
846
- }
847
- rawResultsFile := filepath .Join (codspeedProfileFolder , "raw_results" , fmt .Sprintf ("%s.json" , hex .EncodeToString (randomBytes )))
848
- file , err := os .Create (rawResultsFile )
849
- if err != nil {
850
- fmt .Fprintf (os .Stderr , "failed to create raw results file: %v\n " , err )
851
- continue
852
- }
853
- output , err := json .MarshalIndent (rawResults , "" , " " )
854
- if err != nil {
855
- fmt .Fprintf (os .Stderr , "failed to marshal raw results: %v\n " , err )
856
- file .Close ()
857
- continue
858
- }
859
- // FIXME: Don't overwrite the file if it already exists
860
- if _ , err := file .Write (output ); err != nil {
861
- fmt .Fprintf (os .Stderr , "failed to write raw results: %v\n " , err )
862
- file .Close ()
863
- continue
864
- }
865
- defer file .Close ()
866
- // END CODSPEED
867
- // ############################################################################################
868
-
869
790
if b .chatty != nil {
870
791
fmt .Fprintf (b .w , "%-*s\t " , s .maxLen , benchName )
871
792
}
0 commit comments