Forge
csharp4405de34
1using System.Diagnostics;
2using System.Globalization;
3using System.Text;
4using CasaField.Core;
5
6var store = args.Length > 0
7 ? args[0]
8 : Path.GetFullPath(Path.Combine(
9 AppContext.BaseDirectory,
10 "..", "..", "..", "..",
11 "..", "casa-ontology-payload", "examples", "agent-stores", "research-agent-lab-v0"));
12
13var query = args.Length > 1 ? args[1] : "import knowledge delta";
14
15if (!File.Exists(Path.Combine(store, "field_state.json")))
16{
17 Console.Error.WriteLine($"missing field_state in {store}");
18 return 1;
19}
20
21var sw = Stopwatch.StartNew();
22var first = CasaFieldHotPath.Run(store, query);
23sw.Stop();
24var coldMs = sw.Elapsed.TotalMilliseconds;
25
26var times = new List<double>(30);
27for (var i = 0; i < 30; i++)
28{
29 sw.Restart();
30 _ = CasaFieldHotPath.Run(store, query);
31 sw.Stop();
32 times.Add(sw.Elapsed.TotalMilliseconds);
33}
34
35times.Sort();
36var sb = new StringBuilder();
37sb.AppendLine("{");
38sb.AppendLine(" \"csharp\": {");
39var inv = CultureInfo.InvariantCulture;
40sb.AppendLine($" \"cold_ms\": {coldMs.ToString("F3", inv)},");
41sb.AppendLine($" \"hot_loop_median_ms\": {times[times.Count / 2].ToString("F3", inv)},");
42sb.AppendLine($" \"hot_loop_p95_ms\": {times[(int)(times.Count * 0.95)].ToString("F3", inv)},");
43sb.AppendLine($" \"hot_loop_min_ms\": {times[0].ToString("F3", inv)},");
44sb.AppendLine($" \"first_field_version\": {first.FieldVersion},");
45sb.AppendLine($" \"first_stale\": {(first.Stale ? "true" : "false")},");
46sb.AppendLine($" \"first_concept_count\": {first.Decoded.ConceptIds.Count}");
47sb.AppendLine(" }");
48sb.AppendLine("}");
49Console.WriteLine(sb.ToString());
50return 0;
51
View only · write via MCP/CIDE