Skip to content

Commit 8472649

Browse files
committed
major perf improvements
1 parent 083e283 commit 8472649

25 files changed

Lines changed: 958467 additions & 1212 deletions

src/Infidex.Benchmark/Infidex.Benchmark.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<None Update="movies.csv">
2222
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2323
</None>
24+
<None Update="movies1M.csv">
25+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
26+
</None>
2427
</ItemGroup>
2528

2629
<ItemGroup>

src/Infidex.Benchmark/MovieData.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,30 @@ public static List<MovieRecord> LoadMovies()
3434
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
3535
{
3636
PrepareHeaderForMatch = args => args.Header.ToLower(),
37-
MissingFieldFound = null // Ignore missing fields
37+
MissingFieldFound = null, // Ignore missing fields
38+
HeaderValidated = null // Ignore missing headers
3839
};
3940

40-
string filePath = Path.Combine(AppContext.BaseDirectory, "movies.csv");
41+
string filePath = Path.Combine(AppContext.BaseDirectory, "movies1M.csv");
42+
43+
// Try to find 1M dataset
44+
string[] possiblePaths =
45+
{
46+
Path.Combine(AppContext.BaseDirectory, "../../../../src/Infidex.Tests/movies1M.csv"),
47+
Path.Combine(AppContext.BaseDirectory, "../../../../src/Infidex.Example/movies.csv"),
48+
filePath
49+
};
50+
51+
foreach (var path in possiblePaths)
52+
{
53+
if (File.Exists(path))
54+
{
55+
filePath = path;
56+
Console.WriteLine($"Loading movies from: {filePath}");
57+
break;
58+
}
59+
}
60+
4161
using (var reader = new StreamReader(filePath))
4262
using (var csv = new CsvReader(reader, config))
4363
{
@@ -47,4 +67,3 @@ public static List<MovieRecord> LoadMovies()
4767
return _cachedMovies;
4868
}
4969
}
50-

src/Infidex.Benchmark/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ static void Main(string[] args)
1111

1212
//BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
1313
}
14-
}
14+
}

src/Infidex.Benchmark/ResultComparison.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ public static void Run()
8888
// Test queries
8989
string[] testQueries =
9090
{
91-
"redeption sh"
91+
"redeption sh",
92+
"shaaawshank",
93+
"shaa awashank",
94+
"redeption"
9295
};
9396

9497
foreach (var queryText in testQueries)
@@ -99,7 +102,10 @@ public static void Run()
99102

100103
// Infidex results
101104
Console.WriteLine("--- INFIDEX RESULTS (Top 5) ---");
105+
var sw = System.Diagnostics.Stopwatch.StartNew();
102106
var infidexResults = infidexEngine.Search(new Infidex.Api.Query(queryText, 5));
107+
sw.Stop();
108+
Console.WriteLine($"Search took: {sw.Elapsed.TotalMilliseconds:F2} ms");
103109
foreach (var result in infidexResults.Records.Take(5))
104110
{
105111
var doc = infidexEngine.GetDocument(result.DocumentId);
@@ -157,4 +163,3 @@ public static void Run()
157163
luceneDirectory.Dispose();
158164
}
159165
}
160-

0 commit comments

Comments
 (0)