Click here to Skip to main content
15,892,161 members
Articles / Programming Languages / Lua

Programming in ObjectScript 1.5

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
25 Mar 2013MIT22 min read 18.6K   125   4  
The ObjectScript is a new embedded programing language that mixes benefits of JavaScript, Lua, Ruby, Python and PHP. The ObjectScript has syntax from JavaScript, multiple results from Lua, sugar syntax from Ruby, magic methods from Python and much more.
#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.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions