public static void RunTestParametred(int count = 100) { var Store = new Store("../../../Databases/int based/"); Store.ReloadFrom(Config.TurtleFileFullPath); SparqlQueryParser.ParseSparql((IStore)Store, BSBMSampleQueries.sq5); //Store.Start(); //Store.Warmup(); for (int i = 0; i < 12; i++) { BSBmParams bsBmParams = new BSBmParams(Store); var paramvaluesFilePath = string.Format(@"..\..\examples\bsbm\queries\parameters\param values for{0}m {1} query.txt", 1, i + 1); var qFile = string.Format(@"..\..\examples\bsbm\queries\parameters\{0}.rq", i + 1); using (StreamReader streamParameters = new StreamReader(paramvaluesFilePath)) using (StreamReader streamQuery = new StreamReader(qFile)) { string qparams = streamQuery.ReadToEnd(); Stopwatch timer = new Stopwatch(); for (int j = 0; j < count; j++) { string q = BSBmParams.QueryReadParameters(qparams, streamParameters); var sparqlResults = SparqlQueryParser.ParseSparql((IStore)Store, q).Run(); timer.Start(); sparqlResults.Results.Count(); timer.Stop(); } using (StreamWriter r = new StreamWriter(@"..\..\output.txt", true)) { r.WriteLine(); r.WriteLine("one query {0}, {1} times", i + 1, count); r.WriteLine("milions " + 1); r.WriteLine("date time " + DateTime.Now); r.WriteLine("total ms " + timer.ElapsedMilliseconds); double l = ((double)timer.ElapsedMilliseconds) / count; r.WriteLine("ms " + l); r.WriteLine("qps " + (int)(1000.0 / l)); string q = BSBmParams.QueryReadParameters(qparams, streamParameters); r.WriteLine("next results count: {0}", SparqlQueryParser.ParseSparql((IStore)Store, q).Run().Results.Count()); } } } }
private static void test(Store store) { var sparqlQuery = SparqlQueryParser.ParseSparql(store, "Select * { ?s ?p \"kl\"@ru . Filter( ?s > 0 ) }"); Console.WriteLine("parse ok"); var res = sparqlQuery.Run(); Console.WriteLine(res.ToCommaSeparatedValues()); using (var stream = new StreamWriter("../../q.xml")) { var formatter = new XmlSerializer(typeof(SparqlQuery.SparqlClasses.Query.SparqlQuery)); // var formatter=new BinaryFormatter(); formatter.Serialize(stream.BaseStream, sparqlQuery); } }
private static void SubTestRun(StreamReader streamQueryParameters, int i1, IStore Store) { double[] results = new double[12]; double[] minimums = Enumerable.Repeat(double.MaxValue, 12).ToArray(); double[] maximums = new double[12]; double maxMemoryUsage = 0; double[] totalparseMS = new double[12]; double[] totalrun = new double[12]; for (int j = 0; j < i1; j++) { for (int i = 0; i < 12; i++) { string file = string.Format(@"..\..\examples\bsbm\queries\parameters\{0}.rq", i + 1); var readAllText = File.ReadAllText(file); readAllText = BSBmParams.QueryReadParameters(readAllText, streamQueryParameters); var timer = new Stopwatch(); SparqlQuery.SparqlClasses.Query.SparqlQuery sparqlQuery = null; // if (i == 0) { sparqlQuery = SparqlQueryParser.ParseSparql(Store, readAllText); } totalparseMS[i] += timer.GetTimeWthLast2Digits(); var st1 = DateTime.Now; //if (i == 0) { var sparqlResultSet = sparqlQuery.Run().ToJson(); } totalrun[i] += (DateTime.Now - st1).Ticks / 10000L; var totalMilliseconds = timer.GetTimeWthLast2Digits(); var memoryUsage = GC.GetTotalMemory(false); if (memoryUsage > maxMemoryUsage) { maxMemoryUsage = memoryUsage; } if (minimums[i] > totalMilliseconds) { minimums[i] = totalMilliseconds; } if (maximums[i] < totalMilliseconds) { maximums[i] = totalMilliseconds; } results[i] += totalMilliseconds; // File.WriteAllText(Path.ChangeExtension(file.FullName, ".txt"), resultString); //.Save(Path.ChangeExtension(file.FullName,".xml")); } } using (StreamWriter r = new StreamWriter(@"..\..\output.txt", true)) { r.WriteLine("milions " + 1); r.WriteLine("date time " + DateTime.Now); r.WriteLine("max memory usage " + maxMemoryUsage); r.WriteLine("average " + string.Join(", ", results.Select(l => l == 0 ? "inf" : (500 * 1000 / l).ToString()))); r.WriteLine("minimums " + string.Join(", ", minimums)); r.WriteLine("maximums " + string.Join(", ", maximums)); r.WriteLine("total parse " + string.Join(", ", totalparseMS)); r.WriteLine("total run " + string.Join(", ", totalrun)); r.WriteLine("total " + totalparseMS.Sum() + totalrun.Sum()); // r.WriteLine("countCodingUsages {0} totalMillisecondsCodingUsages {1}", TripleInt.EntitiesCodeCache.Count, TripleInt.totalMilisecondsCodingUsages); //r.WriteLine("EWT average search" + EntitiesMemoryHashTable.total / EntitiesMemoryHashTable.count); //r.WriteLine("EWT average range" + EntitiesMemoryHashTable.totalRange / EntitiesMemoryHashTable.count); } }
public static void OneLUMB(IStore store, int i, int count) { SparqlQueryParser.ParseSparql(store, BSBMSampleQueries.sq5); store.Warmup(); { var file = new FileInfo(string.Format(@"..\..\..\Testing\examples\lubm\q ({0}).rq", i)); var q = File.ReadAllText(file.FullName); double min = int.MaxValue, max = -1, average = 0; double averageParse = 0; double averageCLS = 0; double averageRun = 0; for (int j = 0; j < count; j++) { Stopwatch timer = new Stopwatch(); timer.Restart(); var sparqlQuery = SparqlQueryParser.ParseSparql(store, q); timer.Stop(); double time1 = timer.GetTimeWthLast2Digits(); averageParse += (double)((int)(100 * time1 / count)) / 100; timer.Restart(); var sparqlResultSet = sparqlQuery.Run(); timer.Stop(); double time2 = timer.GetTimeWthLast2Digits(); averageCLS += (double)((int)(100 * time2 / count)) / 100; timer.Restart(); sparqlResultSet.Results.ToArray(); timer.Stop(); double time3 = timer.GetTimeWthLast2Digits(); averageRun += (double)((int)(100 * time3 / count)) / 100; var time = time1 + time2 + time3; average += (double)((int)(100 * time)) / 100; if (time > max) { max = time; } if (min > time) { min = time; } File.WriteAllText(@"..\..\..\Testing\examples\lubm\q ({0}).json", sparqlResultSet.ToJson()); } using (StreamWriter r = new StreamWriter(@"..\..\output.txt", true)) { r.WriteLine(DateTimeOffset.Now); r.WriteLine("q " + i); r.WriteLine("average " + average / count); r.WriteLine("qps " + ((double)((int)(100000 * count / average)) / 100)); r.WriteLine("min " + min); r.WriteLine("max " + max); r.WriteLine("memory usage (bytes)" + GC.GetTotalMemory(false)); r.WriteLine("parse (ms)" + averageParse); r.WriteLine("create linq stack " + averageCLS); r.WriteLine("run " + averageRun); } } }
public static void Run() { double[] memoryUsage = new double[12]; double[] totalparseMS = new double[12]; double[] totalCreateLinqStack = new double[12]; double[] totalrun = new double[12]; Console.WriteLine("bsbm with constants"); var timer = new Stopwatch(); // var Store = new Store("../../../Databases/int based/"); var Store = new RDFRamStore(); Store.ReloadFrom(@"..\..\..\" + Config.TurtleFileFullPath); //разогрев транслятора и интерпретатора // SparqlQueryParser.Parse((IStore) Store, BSBMSampleQueries.sq5); for (int i = 0; i < 12; i++) { string file = $@"examples\bsbm\queries\with constants\{i}.rq"; var readAllText = File.ReadAllText(file); GC.Collect(); timer.Restart(); var sparqlQuery = SparqlQueryParser.ParseSparql((IStore)Store, readAllText); timer.Stop(); totalparseMS[i] += timer.GetTimeWthLast2Digits(); timer.Restart(); var sparqlResultSet = sparqlQuery.Run(); timer.Stop(); totalCreateLinqStack[i] += timer.GetTimeWthLast2Digits(); timer.Restart(); sparqlResultSet.Results.ToArray(); timer.Stop(); totalrun[i] += timer.GetTimeWthLast2Digits(); memoryUsage[i] = GC.GetTotalMemory(false); File.WriteAllText(Path.ChangeExtension(file, ".json"), sparqlResultSet.ToJson()); } using (StreamWriter r = new StreamWriter(@"output.txt", true)) { r.WriteLine("date time " + DateTime.Now); r.WriteLine("memory usage (bytes)" + string.Join(", ", memoryUsage)); r.WriteLine("parse (ms)" + string.Join(", ", totalparseMS)); r.WriteLine("total parse " + totalparseMS.Sum()); r.WriteLine("create linq stack " + string.Join(", ", totalCreateLinqStack)); r.WriteLine("total create linq stack " + totalCreateLinqStack.Sum()); r.WriteLine("run " + string.Join(", ", totalrun)); r.WriteLine("parse + create linq stack + run " + string.Join(", ", totalrun.Select((d, i) => d + totalCreateLinqStack[i] + totalparseMS[i]) .Select(d => d.ToString().Replace(",", ".")))); r.WriteLine("total run " + totalrun.Sum()); r.WriteLine("total " + (totalparseMS.Sum() + totalCreateLinqStack.Sum() + totalrun.Sum())); } }