Exemple #1
0
        public static void Run(string dataset, Tuple <string, Pattern[]> namedQuery)
        {
            using (var db = new Database(dataset)) {
                // open database
                db.Open();

                // get query plan
                var plan = db.GetQueryPlan(namedQuery.Item2);

#if DEBUG
                // start process monitoring...
                ProcessMonitor.Start(100, 4000, 3);
#endif

                // execute query
                var watch = new Stopwatch();
                var c     = 0L;
                watch.Start();
                foreach (var item in db.Query(plan, false))
                {
                    c++;
                }
                watch.Stop();

#if DEBUG
                // ...stop process monitoring
                ProcessMonitor.Stop();
#endif

                // produce reports
                var fNamePrefix = String.Format("{0}.{1}", dataset, namedQuery.Item1);
#if DEBUG
                CSVWriter.WriteProcessMonitorHistory(String.Format("{0}.proc.csv", fNamePrefix));
                TikzWriter.Write(plan, String.Format("{0}.tikz.txt", fNamePrefix), true);
#else
                TikzWriter.Write(plan, String.Format("{0}.tikz.txt", fNamePrefix), false);
#endif
                using (var sw = new StreamWriter(String.Format("{0}.res.txt", fNamePrefix))) {
                    sw.WriteLine(c);
                    sw.Write(watch.ElapsedMilliseconds.ToString());
                }

                // close database
                db.Close();
            }

            // clean up after yourself
            GC.Collect();
        }
Exemple #2
0
        public static void Run(string dataset, Tuple <string, Pattern[]> namedQuery, int numRuns)
        {
            var runTimes = new List <string>();

            for (int i = 0; i < numRuns; i++)
            {
#if DEBUG
                Logger.WriteLine("Starting {0}, query {1}, run {2:00}...", dataset, namedQuery.Item1, i + 1);
#endif
                using (var db = new Database(dataset)) {
                    // open database
                    db.Open();

                    // get query plan
                    var plan = db.GetQueryPlan(namedQuery.Item2);

#if DEBUG
                    // start process monitoring...
                    ProcessMonitor.Start(100, 4000, 3);
#endif

                    // execute query
                    var watch = new Stopwatch();
                    var c     = 0L;
                    watch.Start();
                    foreach (var item in db.Query(plan, false))
                    {
                        c++;
                    }
                    watch.Stop();

#if DEBUG
                    // ...stop process monitoring
                    ProcessMonitor.Stop();
#endif

                    var dir = String.Format("{0}.{1}", dataset, namedQuery.Item1);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    // produce reports
                    var fNamePrefix = String.Format("{0}.{1}\\run-{2:00}", dataset, namedQuery.Item1, i);
#if DEBUG
                    CSVWriter.WriteProcessMonitorHistory(String.Format("{0}.proc.csv", fNamePrefix));
                    TikzWriter.Write(plan, String.Format("{0}.tikz.txt", fNamePrefix), true);
#else
                    TikzWriter.Write(plan, String.Format("{0}.tikz.txt", fNamePrefix), false);
#endif
                    using (var sw = new StreamWriter(String.Format("{0}.res.txt", fNamePrefix))) {
                        sw.WriteLine(c);
                        var rt = watch.ElapsedMilliseconds.ToString();
                        runTimes.Add(rt);
                        sw.Write(rt);
                    }

                    // close database
                    db.Close();
                }

                // clean up after yourself
                GC.Collect();
            }

            // write times for all runs
            using (var sw = new StreamWriter(String.Format("{0}.{1}\\times.txt", dataset, namedQuery.Item1))) {
                foreach (var item in runTimes)
                {
                    sw.WriteLine(item);
                }
            }
        }