MCPcopy
hub / github.com/perkeep/perkeep / benchmarkWrite

Function benchmarkWrite

pkg/test/integration/diskpacked_test.go:42–64  ·  view source on GitHub ↗
(b *testing.B, cfg string)

Source from the content-addressed store, hash-verified

40}
41
42func benchmarkWrite(b *testing.B, cfg string) {
43 w, err := test.WorldFromConfig(cfg)
44 if err != nil {
45 b.Fatalf("could not create server for config: %v\nError: %v", cfg, err)
46 }
47 testFile := filepath.Join(w.SourceRoot(), testFileRel)
48 createTestFile(b, testFile, testFileSize)
49 defer os.Remove(testFile)
50 b.ResetTimer()
51 b.StopTimer()
52 for i := 0; i < b.N; i++ {
53 err = w.Start()
54 if err != nil {
55 b.Fatalf("could not start server for config: %v\nError: %v", cfg, err)
56 }
57 b.StartTimer()
58 test.MustRunCmd(b, w.Cmd("pk-put", "file", testFile))
59 b.StopTimer()
60 w.Stop()
61 }
62
63 b.SetBytes(int64(testFileSize))
64}
65
66func createTestFile(tb testing.TB, file string, n int) {
67 f, err := os.Create(file)

Callers 2

BenchmarkLocalFunction · 0.85
BenchmarkDiskpackedFunction · 0.85

Calls 9

WorldFromConfigFunction · 0.92
MustRunCmdFunction · 0.92
createTestFileFunction · 0.85
SourceRootMethod · 0.80
CmdMethod · 0.80
FatalfMethod · 0.65
RemoveMethod · 0.65
StartMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected