📄 profiling.cpp.svn-base
字号:
#include "profiling.h"/* Can't be used for *very* precise profiling - ignores execution time of RDTSC */ticksticks::now(){ ticks res; asm { pushad; popad; pushad; db 0fh,031h; mov dword ptr res._ticks_val_489508349581424 , eax; mov dword ptr res._ticks_val_489508349581424 + 4, edx; popad; } return res;}#include <dos.h>#include <iomanip>floatticks::compute_scale(){ struct time t1, t2; gettime(&t1); ticks ticks1 = ticks::now(); int j = 0; for (int i = 0; i < 10000000; i++) ++j; gettime(&t2); ticks ticks2 = ticks::now(); double s1 = t1.ti_hour*3600.0 + t1.ti_min*60.0 + t1.ti_sec + t1.ti_hund*0.01; double s2 = t2.ti_hour*3600.0 + t2.ti_min*60.0 + t2.ti_sec + t2.ti_hund*0.01; double secs = s2 - s1; ticks diff_ticks = ticks2 - ticks1; scale = secs / (diff_ticks.val);// cout << "Scale is " << scale << endl;// cout << "Freq is " << fixed << setprecision(2) << 1 / scale << endl; return scale;}float ticks::scale = 0;#include <vector>using namespace std;int main(){ ticks::compute_scale(); ticks start(ticks::now()); int j = 0; for (int i = 0; i < 10; i++) ++j; cout << ticks::now() - start << endl; ticks_counter counter; counter.start(); for (int i = 0; i < 10; i++) ++j; counter.stop(); cout << counter << endl; ticks_counter fucken_clear, swap; vector<int> dummy; vector<int> v; fucken_clear.start(); dummy.clear(); fucken_clear.stop(); swap.start(); dummy.swap(v); swap.stop(); cout << "clear operation took " << fucken_clear << endl; cout << "swap took " << swap << endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -