(b *testing.B)
| 3135 | } |
| 3136 | |
| 3137 | func 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 | |
| 3167 | func TestAugmentedIsOfflineError(t *testing.T) { |
| 3168 | markTestForSharding(t, 12) |
nothing calls this directly
no test coverage detected