Beispiel #1
0
        static async Task Main(string[] args)
        {
            var cs         = "mongodb://localhost/PerformanceTest";
            var collection = new TestDocumentCollection(cs);

            //await InsertRandomDocuments(collection);

            using (new StopwatchScope(sw => Console.WriteLine($"Sync list duration: {sw.ElapsedMilliseconds} ms")))
            {
                var count = GetDocumentCount(await collection.GetDocumentsAsList());
                var mem   = GC.GetTotalMemory(true);
                Console.WriteLine($"Sync list count: {count}, memory: {Process.GetCurrentProcess().WorkingSet64 / 1_048_576} MB, {mem / 1_048_576} MB");
            }

            using (new StopwatchScope(sw => Console.WriteLine($"Async list duration: {sw.ElapsedMilliseconds} ms")))
            {
                var count = await GetDocumentCountAsync(await collection.GetDocumentsAsync());

                var mem = GC.GetTotalMemory(true);
                Console.WriteLine($"Async list count: {count}, memory: {Process.GetCurrentProcess().WorkingSet64 / 1_048_576} MB, {mem / 1_048_576} MB");
            }
        }
Beispiel #2
0
 private static async Task InsertRandomDocuments(TestDocumentCollection collection)
 {
     await collection.InsertManyAsync(GenerateRandomDocuments(1_000_000).ToList());
 }