MCPcopy
hub / github.com/ddworken/hishtory / BenchmarkQuery

Function BenchmarkQuery

client/integration_test.go:3137–3165  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

3135}
3136
3137func BenchmarkQuery(b *testing.B) {
3138 b.StopTimer()
3139 // Setup with an install with a lot of entries
3140 tester := zshTester{}
3141 defer testutils.BackupAndRestore(b)()
3142 testutils.ResetLocalState(b)
3143 installHishtory(b, tester, "")
3144 numSyntheticEntries := 100_000
3145 createSyntheticImportEntries(b, numSyntheticEntries)
3146 ctx := hctx.MakeContext()
3147 numImported, err := lib.ImportHistory(ctx, false, true)
3148 require.NoError(b, err)
3149 require.GreaterOrEqual(b, numImported, numSyntheticEntries)
3150 db := hctx.GetDb(ctx)
3151 for i := range 1000 {
3152 e := testutils.MakeFakeHistoryEntry(strings.Repeat(fmt.Sprintf("this is a long command %d", i), 100))
3153 require.NoError(b, db.Create(e).Error)
3154 }
3155
3156 // Benchmark it
3157 for n := 0; n < b.N; n++ {
3158 ctx := hctx.MakeContext()
3159 // Benchmarked code:
3160 b.StartTimer()
3161 _, err := lib.Search(ctx, hctx.GetDb(ctx), "this is a long command 123", 100)
3162 b.StopTimer()
3163 require.NoError(b, err)
3164 }
3165}
3166
3167func TestAugmentedIsOfflineError(t *testing.T) {
3168 markTestForSharding(t, 12)

Callers

nothing calls this directly

Calls 9

BackupAndRestoreFunction · 0.92
ResetLocalStateFunction · 0.92
MakeContextFunction · 0.92
ImportHistoryFunction · 0.92
GetDbFunction · 0.92
MakeFakeHistoryEntryFunction · 0.92
SearchFunction · 0.92
installHishtoryFunction · 0.85

Tested by

no test coverage detected