如何计算将数据发送到azure服务总线主题的时间

时间:2017-11-16 00:14:46

标签: azure azure-functions azure-servicebus-topics

我试图计算从我的设备发送数据到azure服务总线主题之间的时间。我有天蓝色的功能来听主题。此外,我发送到主题的数据有一个DateTime。在azure函数中,我创建新的DateTime并从主题数据中减去DateTime。它应该给我发送到接收之间的时间。但是,我得到了很多负面数据。

    try
    {
        await client.PostAsJsonAsync("api/device", device);
        releaseLoop= true;

    }
    catch (Exception e)
    {
        log.Info("Exception Message: "+e);
    }

    finally
    {
        log.Info($"{data.DeviceName} Total runing time "+(DateTime.UtcNow-data.timerInfo).Milliseconds+"ms");
    }



logInfo from azure function.
2017-11-13T04:44:36.976 3060 ipad Total runing time 412ms
2017-11-13T04:44:36.976 Function completed (Success, Id=57c528fe-589d-4edc-b285-4dfe481f2aee, Duration=119ms)
2017-11-13T04:44:37.427 Function started (Id=33469551-3873-468d-8ecf-df0b72d8e951)
2017-11-13T04:44:36.352 3049 iphone Total runing time 910ms
2017-11-13T04:44:36.352 Function completed (Success, Id=d233a8e7-1852-4d72-a8f6-5ebc9c4b3d36, Duration=130ms)
2017-11-13T04:44:36.368 Function started (Id=ed19f6e8-7db2-440c-872f-205078a6c0f5)
2017-11-13T04:44:36.477 3061 ipad Total runing time -188ms
2017-11-13T04:44:36.477 Function completed (Success, Id=ed19f6e8-7db2-440c-872f-205078a6c0f5, Duration=109ms)
2017-11-13T04:44:36.687 Function started (Id=feee0174-7461-4ab4-939d-48ca8377ae10)
2017-11-13T04:44:36.793 3064 ipad Total runing time -179ms
2017-11-13T04:44:36.793 Function completed (Success, Id=feee0174-7461-4ab4-939d-48ca8377ae10, Duration=117ms)
2017-11-13T04:44:37.191 Function started (Id=487d5657-5433-48f0-b4bb-e24e80375d5a)
2017-11-13T04:44:37.301 3069 surface pro Total runing time -181ms
2017-11-13T04:44:37.301 Function completed (Success, Id=487d5657-5433-48f0-b4bb-e24e80375d5a, Duration=108ms)
2017-11-13T04:44:36.726 3063 iphone Total runing time -143ms

1 个答案:

答案 0 :(得分:0)

一种方法是在同一台机器上同时设置发送方和监听方的测试 - 避免时钟偏差问题。