github.com/vlifesystems/rulehunter@v0.0.0-20180501090014-673078aa4a83/html/front_test.go (about) 1 package html 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 "testing" 8 9 "github.com/vlifesystems/rulehunter/config" 10 "github.com/vlifesystems/rulehunter/internal/testhelpers" 11 "github.com/vlifesystems/rulehunter/progress" 12 ) 13 14 /************************* 15 Benchmarks 16 *************************/ 17 18 func BenchmarkGenerateFront(b *testing.B) { 19 cfgDir := testhelpers.BuildConfigDirs(b, true) 20 defer os.RemoveAll(cfgDir) 21 22 cfg := &config.Config{ 23 ExperimentsDir: filepath.Join(cfgDir, "experiments"), 24 WWWDir: filepath.Join(cfgDir, "www"), 25 BuildDir: filepath.Join(cfgDir, "build"), 26 MaxNumRecords: 100, 27 MaxNumProcesses: 4, 28 } 29 pm, err := progress.NewMonitor( 30 filepath.Join(cfg.BuildDir, "progress"), 31 ) 32 if err != nil { 33 b.Fatalf("progress.NewMonitor: %s", err) 34 } 35 36 for i := 0; i < 100; i++ { 37 testhelpers.CopyFile( 38 b, 39 filepath.Join("fixtures", "reports", "bank-profit.json"), 40 filepath.Join(cfgDir, "build", "reports"), 41 fmt.Sprintf("bank-profit-%02d.json", i), 42 ) 43 } 44 b.ResetTimer() 45 for i := 0; i < b.N; i++ { 46 if err := generateFront(cfg, pm); err != nil { 47 b.Fatalf("generateFront: %s", err) 48 } 49 } 50 51 }