Esempio n. 1
0
        public override void Process()
        {
            string fileNameFull = Path.GetFullPath("../_work/90-dbstress.db");

            Console.WriteLine("DB file: " + fileNameFull);
            if (File.Exists(fileNameFull))
            {
                File.Delete(fileNameFull);
            }
            DateTime      date   = DateTime.Now;
            Stopwatch     watch  = new Stopwatch();
            List <string> ids    = new List <string>();
            int           cycles = 10;

            Console.WriteLine("Stopwatch > Frequency: " + Stopwatch.Frequency + "; IsHighResolution: " + Stopwatch.IsHighResolution);

            using (ResultRepo rr = new ResultRepo(null, fileNameFull))
            {
                for (int i = 0; i < cycles; ++i)
                {
                    StoredResult sr = new StoredResult("NNN", date, 0, 0, 1200, encRes, encSurv);

                    // Store a single item: measure time
                    watch.Restart();
                    string uid     = rr.StoreResult(sr);
                    long   msStore = watch.ElapsedMilliseconds;
                    ids.Add(uid);
                    // Retrieve all UIDs
                    watch.Restart();
                    foreach (string x in ids)
                    {
                        rr.LoadScore(x);
                    }
                    long msLoad = watch.ElapsedMilliseconds / ids.Count;
                    // Speak out
                    Console.WriteLine("Cycle " + (i + 1).ToString("00") + " > Store: " + msStore.ToString("000") + " msec; load: " + msLoad.ToString("000") + " msec");

                    // No time wasted storing the very last batch
                    if (i == cycles - 1)
                    {
                        break;
                    }
                    // Store 50k items
                    rr.StoreBatch(sr, 50000);
                    // Next day :)
                    date = date.AddDays(1);
                }
            }
        }
Esempio n. 2
0
        private void storeFun(object para)
        {
            ResultRepo rr    = para as ResultRepo;
            Stopwatch  watch = new Stopwatch();

            Thread.Sleep(2000);
            while (finished == 0)
            {
                watch.Restart();
                StoredResult sr = new StoredResult("NNN", DateTime.Now, 0, 0, 1200, encRes, encSurv);
                rr.StoreResult(sr);
                long msec = watch.ElapsedMilliseconds;
                Console.WriteLine("Worker thread stored new result in " + msec + " msec.");
                Thread.Sleep(2000);
            }
        }
Esempio n. 3
0
 public override string ToString()
 {
     return($"e:{JustEvaluated} : {StoredResult?.ToString() ?? "null"} : {Operator?.ToString() ?? "null"} : {Input?.ToString() ?? "null"}");
 }