Ejemplo n.º 1
0
 public void GlobalBenchmarking_MeasureInBetweenValue_InBetweenAreCorrect()
 {
     using (var bench = new Benchmark(e => Assert.AreEqual(40, e.TotalMilliseconds, 5)))
     {
         bench.CheckNow(e => Assert.AreEqual(0, e.TotalMilliseconds, 5));
         Thread.Sleep(20);
         bench.CheckNow(e => Assert.AreEqual(20, e.TotalMilliseconds, 5));
         Thread.Sleep(20);
     }
 }
Ejemplo n.º 2
0
        public void CreateAllThumbnails()
        {
            //var db = this.GetDatabaseState();
            var settings = new DbSettingsComponent(this.Session);
            var areThumbnailsCreated = (settings.Exists("AreThumbnailsCreated"))
                ? bool.Parse(settings["AreThumbnailsCreated"])
                : false;

            if (!areThumbnailsCreated)
            {
                settings["AreThumbnailsCreated"] = false.ToString();
                this.Logger.Info("Creation of the thumbnails");
                using (var bench = new Benchmark(e => this.Logger.InfoFormat("Thumbnails created in {0,3}.{1:###} sec", e.Seconds, e.Milliseconds)))
                {
                    var pictures = (from p in this.Session.Query<Picture>()
                                    select p).ToList();
                    new ImageHelper().TryCreateThumbnail(pictures);
                    using (var tx = this.Session.BeginTransaction())
                    {
                        new Updator(this.Session).Update(pictures);
                        bench.CheckNow(e => this.Logger.DebugFormat("Thumbnails created in memory in {0,3}.{1:###} sec", e.Seconds, e.Milliseconds));
                        areThumbnailsCreated = true;
                        settings["AreThumbnailsCreated"] = areThumbnailsCreated.ToString();
                        tx.Commit();
                        bench.CheckNow(e => this.Logger.DebugFormat("Transaction commited {0,3}.{1:###} sec", e.Seconds, e.Milliseconds));
                    }
                }
            }
            else { this.Logger.Debug("Thumbnails creation already executed. Action aborded."); }
        }