簡體   English   中英

ArangoDb .Net驅動程序性能

[英]ArangoDb .Net driver performance

我正在嘗試新的ArangoDb-Net重新實現驅動程序https://github.com/yojimbo87/ArangoDB-NET/tree/reimplement 今天是我第一次嘗試表演。 當我使用araongosh執行插入時。 它每秒可以插入大約5000條記錄。 但是,當我使用.Net驅動程序執行相同的更新時。 我花了大約2分鍾來執行相同的插入。 我可以知道我做錯了嗎? 謝謝。

[編輯] 用github討論完成問題我已經用我的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);

完成操作需要3.375秒。

我用.Net驅動程序做類似的事情,它花了差不多9.5797819。 幾乎三倍的arangosh。 這是.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; }
}

如果我刪除評論:

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

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

性能幾乎是30倍。 完成時間為99.8789133秒。 實際上,我只是執行其他更新以添加其他列。

您能否就上述代碼的問題提出建議? 謝謝。

yojimbo87更深入地研究了這個問題。 測試不同的層揭示了問題。

合並請求#32可以在創建,更新和替換通用對象的文檔/邊緣時提高性能約57%。

在本地機器上,使用給定的Employee示例對象創建單個文檔現在在使用驅動程序的10k迭代循環中平均需要約0.4ms。 原始.NET HTTP請求(沒有任何ArangoDB驅動程序抽象)在10k循環中需要大約0.35ms。 通過從通用對象到字典的轉換來實現差異,這需要由於屬性處理(例如IgnoreField,IgnoreNullValue和AliasField)而完成。

NuGet包已更新以反映這一改進。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM