public void TestSimpleSequentialHttpPostRequests(int iterationCount) { Console.WriteLine("Operation start: TestSimpleSequentialHttpPostRequests\n"); var db = new ADatabase(Database.Alias); //ServicePointManager.DefaultConnectionLimit = 40; //ServicePointManager.Expect100Continue = false; //ServicePointManager.UseNagleAlgorithm = false; ExecuteTimedTest(iterationCount, () => { var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var jsonEntity = JSON.ToJSON(entity); var response = SimpleHttpPostCreateDocument( "http://localhost:8529/_db/" + Database.TestDatabaseGeneral + "/_api/document?collection=" + Database.TestDocumentCollectionName, jsonEntity ); var deserializedResponse = JSON.ToObject <Dictionary <string, object> >(response); }); Console.WriteLine("\nOperation end: TestSimpleSequentialHttpPostRequests"); }
public void TestSimpleSequentialHttpPostRequests() { Console.WriteLine("Operation start: TestSimpleSequentialHttpPostRequests"); var db = new ADatabase(Database.Alias); var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var jsonEntity = JSON.ToJSON(entity); ServicePointManager.DefaultConnectionLimit = 40; ServicePointManager.Expect100Continue = false; ServicePointManager.UseNagleAlgorithm = false; ExecuteTimedTest(10, () => { for (int i = 0; i < 10000; i++) { SimpleHttpPostCreateDocument( "http://localhost:8529/_db/" + Database.TestDatabaseGeneral + "/_api/document?collection=" + Database.TestDocumentCollectionName, jsonEntity ); } }); // Stopwatch stopwatch = Stopwatch.StartNew(); // // for (int i = 0; i < 10000; i++) // { // SimpleHttpPostCreateDocument( // "http://localhost:8529/_db/" + Database.TestDatabaseGeneral + "/_api/document?collection=" + Database.TestDocumentCollectionName, // jsonEntity // ); // } // // Console.WriteLine("Elapsed time [s]: {0}", stopwatch.Elapsed.TotalMilliseconds / 1000); Console.WriteLine("Operation end: TestSimpleSequentialHttpPostRequests"); }
public void TestSimpleParallelHttpPostRequests() { var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var jsonEntity = JSON.ToJSON(entity); var threadCount = 10; var tasks = new Task[threadCount]; Stopwatch stopwatch = Stopwatch.StartNew(); for (int i = 0; i < threadCount; i++) { tasks[i] = Task.Factory.StartNew(() => { int messages_sent_by_one_task = 0; while (messages_sent_by_one_task < 100) { SimpleHttpPostCreateDocument( "http://localhost:8529/_db/" + Database.TestDatabaseGeneral + "/_api/document?collection=" + Database.TestDocumentCollectionName, jsonEntity ); messages_sent_by_one_task++; } }); } while (tasks.Any(t => !t.IsCompleted)) { } Console.WriteLine("Elapsed time [s]: {0}", stopwatch.Elapsed.TotalMilliseconds / 1000); }
public void TestRestSharpHttpPostRequests() { Console.WriteLine("Operation start: TestRestSharpHttpPostRequests"); var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var jsonEntity = JSON.ToJSON(entity); ServicePointManager.DefaultConnectionLimit = 40; ServicePointManager.Expect100Continue = false; ServicePointManager.UseNagleAlgorithm = false; var client = new RestClient("http://localhost:8529"); var request = new RestRequest("_db/" + Database.TestDatabaseGeneral + "/_api/document", Method.POST); request.AddParameter("collection", Database.TestDocumentCollectionName); request.AddBody(jsonEntity); Stopwatch stopwatch = Stopwatch.StartNew(); for (int i = 0; i < 10000; i++) { var response = client.Execute(request); } Console.WriteLine("Elapsed time [s]: {0}", stopwatch.Elapsed.TotalMilliseconds / 1000); Console.WriteLine("Operation end: TestRestSharpHttpPostRequests"); }
public void TestArangoClientSequentialInsertion(int iterationCount) { Console.WriteLine("Operation start: TestArangoClientSequentialInsertion\n"); var db = new ADatabase(Database.Alias); ExecuteTimedTest(iterationCount, () => { var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var createResult = db.Document.Create(Database.TestDocumentCollectionName, entity); }); Console.WriteLine("\nOperation end: TestArangoClientSequentialInsertion"); }
public void TestSimpleParallelHttpPostRequests() { var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var jsonEntity = JSON.ToJSON(entity); var threadCount = 10; var tasks = new Task[threadCount]; Stopwatch stopwatch = Stopwatch.StartNew(); for (int i = 0; i < threadCount; i++) { tasks[i] = Task.Factory.StartNew(() => { int messages_sent_by_one_task = 0; while(messages_sent_by_one_task < 100) { SimpleHttpPostCreateDocument( "http://localhost:8529/_db/" + Database.TestDatabaseGeneral + "/_api/document?collection=" + Database.TestDocumentCollectionName, jsonEntity ); messages_sent_by_one_task++; } }); } while (tasks.Any(t => !t.IsCompleted)) { } Console.WriteLine("Elapsed time [s]: {0}", stopwatch.Elapsed.TotalMilliseconds / 1000); }
public void TestSimpleSequentialHttpPostRequests(int iterationCount) { Console.WriteLine("Operation start: TestSimpleSequentialHttpPostRequests\n"); var db = new ADatabase(Database.Alias); //ServicePointManager.DefaultConnectionLimit = 40; //ServicePointManager.Expect100Continue = false; //ServicePointManager.UseNagleAlgorithm = false; ExecuteTimedTest(iterationCount, () => { var entity = new PerformanceEntity(); entity.Id = "1234567890123456789012345678901234"; entity.Key = "1234567"; entity.Revision = "1234567"; entity.Name = "Mohamad Abu Bakar"; entity.IcNumber = "1234567-12-3444"; entity.Department = "IT Department"; entity.Height = 1234; entity.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3); entity.Salary = 3333; var jsonEntity = JSON.ToJSON(entity); var response = SimpleHttpPostCreateDocument( "http://localhost:8529/_db/" + Database.TestDatabaseGeneral + "/_api/document?collection=" + Database.TestDocumentCollectionName, jsonEntity ); var deserializedResponse = JSON.ToObject<Dictionary<string, object>>(response); }); Console.WriteLine("\nOperation end: TestSimpleSequentialHttpPostRequests"); }