Start() public method

Starts measuring ESENT work.
public Start ( ) : void
return void
Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new EsentStopwatch instance and starts
        /// measuring elapsed time.
        /// </summary>
        /// <returns>A new, running EsentStopwatch.</returns>
        public static EsentStopwatch StartNew()
        {
            var stopwatch = new EsentStopwatch();

            stopwatch.Start();
            return(stopwatch);
        }
Exemplo n.º 2
0
 public void TestStoppedStopwatchToString()
 {
     var stopwatch = new EsentStopwatch();
     stopwatch.Start();
     stopwatch.Stop();
     Assert.AreEqual(stopwatch.Elapsed.ToString(), stopwatch.ToString());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new EsentStopwatch instance and starts
 /// measuring elapsed time. 
 /// </summary>
 /// <returns>A new, running EsentStopwatch.</returns>
 public static EsentStopwatch StartNew()
 {
     var stopwatch = new EsentStopwatch();
     stopwatch.Start();
     return stopwatch;
 }
Exemplo n.º 4
0
 public void TestStartAndStopEsentStopwatch()
 {
     var stopwatch = new EsentStopwatch();
     stopwatch.Start();
     stopwatch.Stop();
 }
Exemplo n.º 5
0
 public void TestRunningStopwatchToString()
 {
     var stopwatch = new EsentStopwatch();
     stopwatch.Start();
     Assert.AreEqual("EsentStopwatch (running)", stopwatch.ToString());
 }
Exemplo n.º 6
0
        public void Test()
        {
            var dbdef = new DatabaseDefinition()
                .Table("KV")
                    .Column("Key").AsString().NotNull().Table
                    .Column("Value").AsText().NotNull().Table
                    .Index("IX_KV_Key").Asc("Key").Primary().Table
                .Database;



            var db = new EsentDatabase(@"c:\temp\fluesent\a.db");


            using (var instance = db.CreateInstance())
            {
                using (var session = instance.CreateSession(false))
                {
                    session.CreateDatabase(null, CreateDatabaseGrbit.OverwriteExisting);
                    using (var transaction = session.CreateTransaction())
                    {
                        dbdef.Create(transaction);

                        transaction.Commit();
                    }
                }
            }



            using (var instance = db.CreateInstance())
            {
                using (var session = instance.CreateSession())
                {
                    using (var transaction = session.CreateTransaction())
                    {
                        using (var table = transaction.OpenTable("KV"))
                        {
                            table.CreateInsertRecord()
                                .AddString("Key", "A")
                                .AddString("Value", "Some text")
                                .Insert();

                            table.CreateInsertRecord()
                                .AddString("Key", "B")
                                .AddString("Value", "Another text")
                                .Insert();
                            table.CreateInsertRecord()
                                .AddString("Key", "C")
                                .AddString("Value", "Text for C")
                                .Insert();
                        }
                        transaction.Commit();
                    }
                }
            }
            using (var instance = db.CreateInstance())
            {
                using (var session = instance.CreateSession())
                {
                    using (var transaction = session.CreateTransaction())
                    {
                        var stopwatch = new EsentStopwatch();
                        stopwatch.Start();
                        const int n = 100000;
                        using (var table = transaction.OpenTable("KV"))
                        {
                            foreach (var i in Enumerable.Range(0, n))
                            {
                                table.CreateInsertRecord()
                                    .AddString("Key", "key" + i)
                                    .AddString("Value", "akjsdhakhdkadhkajhd")
                                    .Insert();

                                if ((i % 1000) == 999)
                                {
                                    transaction.Pulse();
                                }
                            }
                        }
                        transaction.Commit();
                        stopwatch.Stop();
                        Console.Out.WriteLine("Inserted {0} records in {1}", n, stopwatch.Elapsed);
                    }
                }
            }
            using (var instance = db.CreateInstance())
            {
                using (var session = instance.CreateSession())
                {
                    using (var transaction = session.CreateTransaction())
                    {
                        using (var table = transaction.OpenTable("KV"))
                        {
                            var mapper = new RecordMapper<KvRecord>()
                                .String("Key", (o, s) => o.Key = s)
                                .String("Value", (o, s) => o.Value = s);

                            //var search = table.CreateSearch(mapper);

                            //var a = search.FindEq(
                            //    table.CreateKey().String("A")
                            //    )
                            //    .ToArray();
                            //var b = search.FindEq(
                            //    table.CreateKey().String("B")
                            //    )
                            //    .ToArray();
                        }
                    }
                }
            }

            using (var instance = db.CreateInstance())
            {
                using (var session = instance.CreateSession())
                {
                    session.AttachDatabase();
                    session.OpenDatabase();
                    using (var transaction = session.CreateTransaction())
                    {
                        using (var table = transaction.OpenTable("KV"))
                        {
                            var mapper = new RecordMapper<KvRecord>()
                                .String("Key", (o, s) => o.Key = s)
                                .String("Value", (o, s) => o.Value = s);

                            //var search = table.CreateSearch(mapper);

                            //foreach (var record in search.FindAll().Take(100))
                            //{
                            //    Console.Out.WriteLine("({0},{1})",record.Key,record.Value);
                            //}
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void InsertAlot()
        {
            var objects = from _ in Enumerable.Range(0, 10000)
                          select new
                                     {
                                         Authorization = new {Roles = new[] {"Admin", "Owner"}},
                                         Content = new
                                                       {
                                                           Html = "a small html fragment on a webpage"
                                                       }

                                     };

            const string dbPath = @"c:\temp\testdb\test.db";
            var db = new EsentDocumentDatabase(dbPath).AlwaysCreateNew();
            //var db = Db;

            var coll = db.GetCollection("pages");

            // Make initial insert to create database
            db.GetCollection("init").Put("init","init");

            var sw = new EsentStopwatch();
            sw.Start();
            var n = 0;
            using (var session = coll.CreateSession())
            {
                const int batchSize = 1000;
                foreach (var o in objects)
                {
                    session.Put("object #" + n, JsonConvert.ToJson(o));
                    if ((n % batchSize) == (batchSize-1))
                    {
                        session.Pulse();
                    }
                    ++n;
                }
                session.Commit();
            }
            sw.Stop();
            Console.Out.WriteLine("Inserting {0} objects took {1}", n, sw.Elapsed);
            Console.Out.WriteLine("Inserting {0} objects took {1} ms/object", n, sw.Elapsed.TotalMilliseconds/n);
            Console.Out.WriteLine("Inserting {0} objects gave {1} objects/s", n, (double)n * 1000d / (double)sw.Elapsed.TotalMilliseconds);

            const int searchCount = 10000;
            var random = new Random();
            sw = new EsentStopwatch();
            sw.Start();
            for (var i = 0; i < searchCount; ++i )
            {
                var obj = coll.Get<IJsonObject>("object #" + random.Next(n));
            }
            sw.Stop();
            Console.Out.WriteLine("Finding {0} objects took {1}", searchCount, sw.Elapsed);
            Console.Out.WriteLine("Finding {0} objects took {1} ms/object", searchCount, sw.Elapsed.TotalMilliseconds/n);
            Console.Out.WriteLine("Finding {0} objects gave {1} objects/s", searchCount, (double)searchCount*1000d / (double)sw.Elapsed.TotalMilliseconds);

            sw = new EsentStopwatch();
            sw.Start();
            for (var i = 0; i < searchCount; ++i )
            {
                var obj = coll.Get<IJsonObject>("object %" + random.Next(n));
            }
            sw.Stop();
            Console.Out.WriteLine("Missing {0} objects took {1}", searchCount, sw.Elapsed);
            Console.Out.WriteLine("Missing {0} objects took {1} ms/object", searchCount, sw.Elapsed.TotalMilliseconds/n);
            Console.Out.WriteLine("Missing {0} objects gave {1} objects/s", searchCount, (double)searchCount * 1000d / (double)sw.Elapsed.TotalMilliseconds);
        }