#ifndef __PROFILE_OS_H__ #define __PROFILE_OS_H__ struct OpcodeProfile { int opcode; int count; double time; OpcodeProfile() { opcode = 0; count = 0; time = 0; } }; extern OpcodeProfile opcodes_usage[]; extern double start_opcode_time; double getTimeSec(); extern int gc_step_count; extern double gc_step_start_time; extern double gc_step_time; extern double gc_sum_time; #define OS_PROFILE_BEGIN_GC do{ gc_step_start_time = getTimeSec(); gc_step_time = 0; }while(false) #define OS_PROFILE_END_GC do{ gc_step_count++; gc_step_time = getTimeSec() - gc_step_start_time; gc_sum_time += gc_step_time; }while(false) #define OS_PROFILE_BEGIN_OPCODE(opcode) do{ gc_step_time = 0; start_opcode_time = getTimeSec(); }while(false) #define OS_PROFILE_END_OPCODE(opcode) do{ \ opcodes_usage[opcode].count++; \ opcodes_usage[opcode].time += getTimeSec() - start_opcode_time - gc_step_time; \ }while(false) #endif //__PROFILE_OS_H__
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The MIT License