简体   繁体   English

在C ++和.NET之间传递时间戳

[英]Passing a time stamp between C++ and .NET

Is there a good way to pass a time stamp between C++ and .net so that when it arrives in .net the delta is worthwhile. 是否有一种在C ++和.net之间传递时间戳的好方法,这样当到达.net时,增量就值得了。

My initial look into this is that the high performance timer uses CPU cycles, while the .net time methods use something else? 我对此的初步了解是,高性能计时器使用CPU周期,而.net时间方法使用其他方法? (I'm not really sure on this point). (我不太确定这一点)。

I'm looking for some guidance/suggestions here. 我在这里寻找一些指导/建议。 The main goal is that a low level request is received by a C++ program it does some kind of processing, control is passed to some .NET code, and then further on again to more .NET code, and along the way a map of values is also passed, so in the C++ portion I'd like to collect a begin/end timestamp, and then another begin and end timestamp as it passes through the pipe line, but I need the timestamps to make sense. 主要目标是C ++程序接收到低级请求,它执行某种处理,将控制权传递给某些.NET代码,然后再传递给更多.NET代码,并沿其传递值也要传递,所以在C ++部分中,我想收集一个开始/结束时间戳记,然后收集另一个通过管道的开始和结束时间戳记,但是我需要这些时间戳记才有意义。

That is to be more or less based on the same clock. 那将或多或少地基于同一时钟。 How can I do this -- I'm probably missing something really simple here I think. 我该怎么做-我想我可能会错过一些非常简单的东西。

Edit: Added note about precision requirement 编辑:添加了有关精度要求的注释

I am aware of C++/CLI, but I guess from what I've found so far (and maybe I am wrong here) is that the high-precision timer measures CPU cycles, and .NET Stopwatch.Elapsed is not CPU time. 我知道C ++ / CLI,但是据目前为止我发现(也许我在这里错了)是高精度计时器测量CPU周期,而.NET Stopwatch.Elapsed不是CPU时间。 I need something that can be more accurate than 15ms which I think is the precision of the time() C function. 我需要比15ms更精确的东西,我认为这是time()C函数的精度。 Something compatible with Stopwatch.Elapsed time would be the most useful. 与秒表兼容的东西。经过的时间将是最有用的。 I apologize that I'm not more specific on the C++ portion -- my C++ is very rusty. 抱歉,我对C ++的部分没有更具体的说明-我的C ++非常生锈。

Just do it. 去做就对了。 Are you aware or using C++/CLI? 您知道还是在使用C ++ / CLI? I use if for this low levlel kind of work because I can jsut handle with .NET objects in C++. 我将if用于这种低级的工作,因为我可以在C ++中使用.NET对象进行处理。 Actually I can write .NET classes in C++. 实际上,我可以用C ++编写.NET类。

C++/CLI is the perfect solution for interacting C++ and .NET code. C ++ / CLI是用于交互C ++和.NET代码的完美解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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