public static void RunTestParametred(AdapterVirtuoso engine, int iq = 5, int count = 100) { var paramvaluesFilePath = string.Format(@"..\..\..\Testing\examples\bsbm\queries\parameters\param values for{0}m {1} query.txt", 1, iq); var file = new FileInfo(string.Format(@"..\..\..\Testing\examples\bsbm\queries\parameters\{0}.rq", iq)); using (StreamReader streamParameters = new StreamReader(paramvaluesFilePath)) using (StreamReader streamQuery = new StreamReader(file.OpenRead())) { string qparams = "sparql " + streamQuery.ReadToEnd(); Stopwatch timer = new Stopwatch(); for (int j = 0; j < count; j++) { string q = BSBmParams.QueryReadParameters(qparams, streamParameters); timer.Start(); engine.Query(q).Count(); timer.Stop(); } using (StreamWriter r = new StreamWriter(@"..\..\output.txt", true)) { r.WriteLine(); r.WriteLine("one query {0}, {1} times", iq, count); r.WriteLine("milions " + 1); r.WriteLine("date time " + DateTime.Now); r.WriteLine("total ms " + timer.ElapsedMilliseconds); double l = timer.ElapsedMilliseconds / count; r.WriteLine("ms на запрос в среденем " + l); r.WriteLine("qps " + (int)(1000.0 / l)); r.WriteLine("next results count: {0}", engine.Query(BSBmParams.QueryReadParameters(qparams, streamParameters)).Count()); } } }
private static void Virtuoso() { //Engine engine=new EngineVirtuoso("HOST=localhost:1550;UID=dba;PWD=dba;Charset=UTF-8;Connection Timeout=5000;", "g"); var engine = new AdapterVirtuoso("HOST=localhost:1550;UID=dba;PWD=dba;Charset=UTF-8;Connection Timeout=5000;", "g"); Stopwatch timer = new Stopwatch(); timer.Start(); // engine.Load(Enumerable.Range(0,1*10*1000).SelectMany(i=>Enumerable.Range(0, 10).Select(j=>Tuple.Create("s"+i, "p"+ j , (ObjectVariants)new OV_string("o" + i + "" + j))))); engine.Query(@"sparql SELECT * WHERE { <s1> ?p ?o } ").Count(); ; timer.Stop(); Console.WriteLine(timer.Elapsed.TotalMilliseconds); return; }
static void Main(string[] args) { string path = ProjectDirectory.GetProjectDirectory(); Console.WriteLine("Start TestGenerator"); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); AdapterVirtuoso engine = new AdapterVirtuoso("HOST=localhost:1550;UID=dba;PWD=dba;Charset=UTF-8;Connection Timeout=500", "g"); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); int npersons = (int)probe.siz; if (probe.sol == "virtuoso7_load") { sw.Restart(); Reload(engine, npersons); sw.Stop(); Console.WriteLine("Load ok. Duration={0}", sw.ElapsedMilliseconds); // 10000: 14.9 сек. probe.ndx = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso7_SelectById") { rnd = new Random(777777777); long sum = 0; sw.Restart(); for (int i = 0; i < probe.nte; i++) { string sid = "person"+ rnd.Next(0, (int)probe.siz - 1); var v = engine.Query("sparql select * { <" + sid + "> ?p ?o }"); sum +=(int) v.First(paramValues => paramValues[0].ToString() == "age")[1]; } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SelectById ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso7_SearchByName") { Console.WriteLine((string)engine.Query("sparql select Count(?p) { ?p a <person>}").First()[0].ToString()); Console.WriteLine((string)engine.Query("sparql select Count(?p) { ?p a <photo_doc>}").First()[0].ToString()); Console.WriteLine((string)engine.Query("sparql select Count(?p) { ?p a <reflection>}").First()[0].ToString()); rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { var intId = rnd.Next(0, (int)probe.siz - 1); string namePrefix = "Pupkin" + intId / 10; //sum += (int)engine.Query(string.Format("sparql select ?s {{ ?s <name> ?o . Filter(strStarts(str(?o), \"{0}\")) }}", namePrefix)).Count(); var enumerable = engine.Query(string.Format("sparql select ?s {{ ?s <name> ?o . Filter(strStarts(str(?o), \"{0}\")) }}", namePrefix)); //foreach (var objectse in enumerable) //{ // foreach (var o in objectse) // { // if (o is SqlRdfBox) // string oname = (string)engine.Query("sparql select ?name { <" + o + "> <name> ?name}").First()[0].ToString(); // if (!o.ToString().StartsWith(namePrefix)) // Console.WriteLine("ERROR!"); // } //} sum += (int)enumerable.Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SearchByName ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso7_GetRelationByPerson") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { string persId = "person"+ rnd.Next(0, (int)probe.siz - 1); sum += engine.Query(string.Format("sparql select ?phname {{?refl <reflected> <{0}> . ?refl <in_doc> ?ph . ?ph <name> ?phname}}", persId)) .Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("GetRelationByPerson ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "unused") { } } res.Close(); }