繁体   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