简体   繁体   中英

ArangoDb .Net driver performance

I am trying on the new ArangoDb-Net reimplement driver https://github.com/yojimbo87/ArangoDB-NET/tree/reimplement . Today is the first time I tried on the performance. When I used the araongosh to perform the insert. It can insert about 5000 records per second. However, when I used the .Net driver to perform the same update. I took about 2 minutes to perform the same insertion. May I know what I have done wrong? Thanks.

[EDIT] completing the question with the github discussion I have tested the code below with my arangosh

count=1;
startTime=+new Date();
console.log(startTime);
while(count <= 10000)
{
db.someCollection.save({"Id":"1234567890123456789012345678901234",
            "Key":1234567,
            "Revision":1234567,
            "Name":"Mohamad Abu Bakar",
            "IC Number":"1234567-12-3444",
            "Department":"IT Department",
            "Height":1234,
            "DateOfBirth":"2015-01-27 03:33",
            "Salary":3333});
    count++;
}
endTime=+new Date();
console.log(endTime);
console.log("Total time taken:" + (endTime - startTime)/1000);

It took 3.375 seconds to complete the operation.

I do the similar thing with the .Net driver and it took almost 9.5797819. Almost triple of the arangosh. Here's the code in .Net:

public static void TestArangoDb()
{
    //ASettings.AddConnection("_system", "127.0.0.1", 8529, false, "_system");
    //var db = new ADatabase("_system");
    //db.Create("trial_sample");

    ASettings.AddConnection("trial_sample",
                           "127.0.0.1", 8529, false, "trial_sample");
    var db2 = new ADatabase("trial_sample");

    db2.Collection.Create("someCollection");

    DateTime startTime = DateTime.Now;
    Console.WriteLine("Start Time: " + startTime.ToLongTimeString());

    for(int count=1; count <= 10000; count++)
    {
        var employee = new Employee();
        employee.Id = "1234567890123456789012345678901234";
        employee.Key = "1234567";
        employee.Revision = "1234567";
        employee.Name = "Mohamad Abu Bakar";
        employee.IcNumber = "1234567-12-3444";
        employee.Department = "IT Department";
        employee.Height = 1234;
        employee.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3);
        employee.Salary = 3333;
        var result = db2.Document.Create<Employee>("someCollection", employee);

        //var updateDocument = new Dictionary<string, object>()
        //    .String("DocumentId", "SomeId");
        //db2.Document.Update(result.Value.String("_id"), updateDocument);
    }

    DateTime endTime = DateTime.Now;
    TimeSpan duration = endTime - startTime;
    Console.WriteLine("End Time: " + endTime.ToLongTimeString());
    Console.WriteLine("Total time taken: " + duration.TotalSeconds);
}

public class Employee 
{
    public string Id { get; set; }
    public string Key { get; set; }
    public string Revision { get; set; }
    public string Name { get; set; }
    public string IcNumber { get; set; }
    public string Email { get; set; }
    public string Department { get; set; }
    public double Height { get; set; }
    public DateTime DateOfBirth { get; set; }
    public decimal Salary { get; set; }
}

If I remove the comment for:

var updateDocument = new Dictionary<string, object>()
    .String("DocumentId", "SomeId");

db2.Document.Update(result.Value.String("_id"), updateDocument);

The performance is almost 30 times. It took 99.8789133 seconds to complete. In fact, I just perform additional update to add additional column.

Could you suggest on the problem on the code above? Thanks.

yojimbo87 researched the issue deeper. Testing The different layers uncovered the problem.

Merge request #32 improves performance when creating, updating and replacing documents/edges from generic objects by ~57%.

On local machine single document creation with given Employee example object now takes on average ~0.4ms in 10k iteration loop using the driver. Raw .NET HTTP request (without any ArangoDB driver abstraction) takes ~0.35ms in 10k loop. Difference is made by conversion from generic object into Dictionary which needs to be done because of attributes processing (such as IgnoreField, IgnoreNullValue and AliasField).

The NuGet package was updated to reflect this improvement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM