anshdadhich commited on
Commit
cee26fa
·
verified ·
1 Parent(s): 6b2f56b

App.xaml.cs: Update to use IndexStore.Finalize() and index.Name(entry) APIs. Fix benchmark to use Entries list instead of removed NameCache property.

Browse files
Files changed (1) hide show
  1. FastSeekWpf/App.xaml.cs +4 -18
FastSeekWpf/App.xaml.cs CHANGED
@@ -115,12 +115,9 @@ public partial class App : Application
115
  PrintHeader("FastSeek CLI");
116
  Console.WriteLine();
117
 
118
- // ── Elevation check ──
119
  bool elevated = Elevation.IsElevated();
120
  if (elevated)
121
- {
122
  PrintLine(ConsoleColor.Green, "Elevation", "Administrator ✓");
123
- }
124
  else
125
  {
126
  PrintLine(ConsoleColor.Red, "Elevation", $"{Elevation.StatusText()} ✗");
@@ -131,7 +128,6 @@ public partial class App : Application
131
  Console.WriteLine();
132
  }
133
 
134
- // 1. Drives
135
  var drives = DriveDiscovery.GetNtfsDrives();
136
  PrintLine(ConsoleColor.Cyan, "Drives", $"{drives.Count} NTFS found");
137
  foreach (var d in drives) PrintDetail($" {d.Letter}: {d.Root}");
@@ -147,11 +143,8 @@ public partial class App : Application
147
  }
148
 
149
  if (!elevated)
150
- {
151
  PrintInfo("Attempting scan anyway (will likely fail without elevation)...");
152
- }
153
 
154
- // 2. Scan
155
  PrintLine(ConsoleColor.Cyan, "Scan", "Reading MFT...");
156
  var index = new IndexStore();
157
  long totalRecords = 0;
@@ -183,13 +176,12 @@ public partial class App : Application
183
  }
184
  }
185
 
186
- index.CompleteIndex();
187
  sw.Stop();
188
 
189
  PrintLine(ConsoleColor.White, "Index", $"{index.Count:N0} entries | {sw.ElapsedMilliseconds}ms | {totalRecords / Math.Max(sw.ElapsedMilliseconds, 1):N0} rec/ms");
190
  Console.WriteLine();
191
 
192
- // 3. Cache
193
  if (index.Count > 0)
194
  {
195
  var cacheSw = Stopwatch.StartNew();
@@ -200,25 +192,22 @@ public partial class App : Application
200
  PrintLine(ConsoleColor.Cyan, "Cache", $"saved {FormatBytes(cacheSize)} in {cacheSw.ElapsedMilliseconds}ms");
201
  }
202
  else
203
- {
204
  PrintLine(ConsoleColor.DarkGray, "Cache", "skipped (empty index)");
205
- }
206
  Console.WriteLine();
207
 
208
- // 4. Benchmark
209
  if (index.Count > 0)
210
  {
211
  PrintLine(ConsoleColor.Cyan, "Benchmark", "1,000 random queries...");
212
  var benchSw = Stopwatch.StartNew();
213
  var rnd = new Random(42);
214
- var names = index.NameCache;
215
  var exclusions = CacheManager.LoadExclusions();
216
  long benchResults = 0;
217
 
218
  for (int i = 0; i < 1000; i++)
219
  {
220
- if (names.Count == 0) break;
221
- var name = names[rnd.Next(names.Count)];
 
222
  if (name.Length < 2) continue;
223
  int start = rnd.Next(name.Length - 1);
224
  int len = rnd.Next(1, Math.Min(name.Length - start, 6));
@@ -232,9 +221,7 @@ public partial class App : Application
232
  PrintLine(ConsoleColor.White, "Result", $"{benchSw.ElapsedMilliseconds}ms total | {qps:N0} qps | {benchResults / 1000.0:F1} avg results");
233
  }
234
  else
235
- {
236
  PrintLine(ConsoleColor.DarkGray, "Benchmark", "skipped (empty index)");
237
- }
238
  Console.WriteLine();
239
  PrintDivider();
240
  Console.WriteLine();
@@ -261,7 +248,6 @@ public partial class App : Application
261
  Console.WriteLine();
262
  }
263
 
264
- // 5. Interactive search
265
  if (index.Count > 0)
266
  {
267
  PrintHeader("Interactive Search (type 'exit' to quit)");
 
115
  PrintHeader("FastSeek CLI");
116
  Console.WriteLine();
117
 
 
118
  bool elevated = Elevation.IsElevated();
119
  if (elevated)
 
120
  PrintLine(ConsoleColor.Green, "Elevation", "Administrator ✓");
 
121
  else
122
  {
123
  PrintLine(ConsoleColor.Red, "Elevation", $"{Elevation.StatusText()} ✗");
 
128
  Console.WriteLine();
129
  }
130
 
 
131
  var drives = DriveDiscovery.GetNtfsDrives();
132
  PrintLine(ConsoleColor.Cyan, "Drives", $"{drives.Count} NTFS found");
133
  foreach (var d in drives) PrintDetail($" {d.Letter}: {d.Root}");
 
143
  }
144
 
145
  if (!elevated)
 
146
  PrintInfo("Attempting scan anyway (will likely fail without elevation)...");
 
147
 
 
148
  PrintLine(ConsoleColor.Cyan, "Scan", "Reading MFT...");
149
  var index = new IndexStore();
150
  long totalRecords = 0;
 
176
  }
177
  }
178
 
179
+ index.Finalize();
180
  sw.Stop();
181
 
182
  PrintLine(ConsoleColor.White, "Index", $"{index.Count:N0} entries | {sw.ElapsedMilliseconds}ms | {totalRecords / Math.Max(sw.ElapsedMilliseconds, 1):N0} rec/ms");
183
  Console.WriteLine();
184
 
 
185
  if (index.Count > 0)
186
  {
187
  var cacheSw = Stopwatch.StartNew();
 
192
  PrintLine(ConsoleColor.Cyan, "Cache", $"saved {FormatBytes(cacheSize)} in {cacheSw.ElapsedMilliseconds}ms");
193
  }
194
  else
 
195
  PrintLine(ConsoleColor.DarkGray, "Cache", "skipped (empty index)");
 
196
  Console.WriteLine();
197
 
 
198
  if (index.Count > 0)
199
  {
200
  PrintLine(ConsoleColor.Cyan, "Benchmark", "1,000 random queries...");
201
  var benchSw = Stopwatch.StartNew();
202
  var rnd = new Random(42);
 
203
  var exclusions = CacheManager.LoadExclusions();
204
  long benchResults = 0;
205
 
206
  for (int i = 0; i < 1000; i++)
207
  {
208
+ if (index.Entries.Count == 0) break;
209
+ var entry = index.Entries[rnd.Next(index.Entries.Count)];
210
+ var name = index.Name(entry);
211
  if (name.Length < 2) continue;
212
  int start = rnd.Next(name.Length - 1);
213
  int len = rnd.Next(1, Math.Min(name.Length - start, 6));
 
221
  PrintLine(ConsoleColor.White, "Result", $"{benchSw.ElapsedMilliseconds}ms total | {qps:N0} qps | {benchResults / 1000.0:F1} avg results");
222
  }
223
  else
 
224
  PrintLine(ConsoleColor.DarkGray, "Benchmark", "skipped (empty index)");
 
225
  Console.WriteLine();
226
  PrintDivider();
227
  Console.WriteLine();
 
248
  Console.WriteLine();
249
  }
250
 
 
251
  if (index.Count > 0)
252
  {
253
  PrintHeader("Interactive Search (type 'exit' to quit)");