找到一个方法的执行时间执行时间、方法

2023-09-03 00:08:46 作者:一介俗人

我想提出一个隐秘图像的项目我的大学。我已经完成了这个项目,并一直保持几种不同的算法隐藏在图像数据。

I am making an Image Steganography project for my college. I have finished the project and have kept several different algorithms for hiding data in images.

我想问问有是没有办法在C#中,通过它我可以找到执行/程序中的两个点之间的运行时间。 例如

What I want to ask is that is there any way in C# through which I can find the execution/running time between two points in a program. For example

//Some Code
//Code to start recording the time.
hideDataUsingAlgorithm();
//Code to stop recording and get the time of execution of the above function. 

我想这样做是为了显示简单的(耗时更少),更高效,但耗时算法之间的差异(使用相同的数据和相同的图像)。我有大约10种不同的算法,彩色和灰度图像。

I want to do this to show the difference between simple(less time consuming) and more efficient but time consuming algorithms (using same data and same image). I have around 10 different algorithms for Color and GrayScale Images.

没有多线程,以便不会成为一个问题。简单的Theres只有一个主线程。

There is no multithreading so that wont be a problem. Theres simply just one main Thread.

推荐答案

System.Environment.TickCount而System.Diagnostics.Stopwatch类是两个很好的工作更精细的分辨率和简单的使用方法。

System.Environment.TickCount and the System.Diagnostics.Stopwatch class are two that work well for finer resolution and straightforward usage.

另请参见:

Is DateTime.Now最好的方式来测量功能的表现? 高分辨率定时器.NET Environment.TickCount VS DateTime.Now What’s以基准程序在Windows中的最佳方法是什么? Is DateTime.Now the best way to measure a function’s performance? High resolution timer in .NET Environment.TickCount vs DateTime.Now What’s the best way to benchmark programs in Windows?
 
精彩推荐
图片推荐