线程上下文切换的性能损耗测试
作者:网络转载 发布时间:[ 2014/6/18 14:20:07 ] 推荐标签:性能损耗测试 性能测试
线程上下文切换的性能损耗到底有多少,一直没有直观的理解,写个程序测试一下。先看看下面的程序(点击下载):

ThreadTester是所有Tester的基类。所有的Tester都干的是同样一件事情,把counter增加到100000000,每次只能加1。
|
1: public abstract class ThreadTester
2: {
3: public const long MAX_COUNTER_NUMBER = 100000000;
4:
5: private long _counter = 0;
6:
7: //获得计数
8: public virtual long GetCounter()
9: {
10: return this._counter;
11: }
12:
13: //增加计数器
14: protected virtual void IncreaseCounter()
15: {
16: this._counter += 1;
17: }
18:
19: //启动测试
20: public abstract void Start();
21:
22: //获得Counter从开始增加到现在的数字所耗的时间
23: public abstract long GetElapsedMillisecondsOfIncreaseCounter();
24:
25: //测试是否正在运行
26: public abstract bool IsTesterRunning();
27: }
|
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。

sales@spasvo.com