hipe_bif1.c
来自「OTP是开放电信平台的简称」· C语言 代码 · 共 905 行 · 第 1/2 页
C
905 行
hp = HAlloc(BIF_P, 7); BIF_RET(TUPLE6(hp,make_small((uint)minor_global_gc), make_small((uint)major_global_gc), make_small(tmp_used_heap), make_small(tmp_allocated_heap), make_small(max_used_global_heap), make_small(max_allocated_global_heap)));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_incremental_gc_info_0(BIF_ALIST_0){#ifdef __BENCHMARK__#if !(defined(BM_COUNTERS) && defined(INCREMENTAL)) Uint minor_gc_cycles = 0; Uint major_gc_cycles = 0; Uint minor_gc_stages = 0; Uint major_gc_stages = 0;#endif Eterm *hp; hp = HAlloc(BIF_P, 5); BIF_RET(TUPLE4(hp,make_small(minor_gc_cycles), make_small(major_gc_cycles), make_small(minor_gc_stages), make_small(major_gc_stages)));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_gc_info_clear_0(BIF_ALIST_0){#ifdef __BENCHMARK__#ifdef BM_COUNTERS minor_gc = 0; major_gc = 0;#ifdef HYBRID minor_global_gc = 0; major_global_gc = 0; gc_in_copy = 0;#ifdef INCREMENTAL minor_gc_cycles = 0; major_gc_cycles = 0; minor_gc_stages = 0; major_gc_stages = 0;#endif#endif#endif#ifdef BM_HEAP_SIZES max_used_heap = 0; max_allocated_heap = 0; max_used_global_heap = 0; max_allocated_global_heap = 0;#endif BIF_RET(am_true);#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_pause_times_0(BIF_ALIST_0){#ifdef BM_TIMERS int i; int total_time = 0, n = 0; int left = 0, right = 0, mid = 0; printf("Pause times in minor collection:\r\n"); for (i = 0; i < MAX_PAUSE_TIME; i++) { if (pause_times[i] > 0) { printf("%d: %ld\r\n",i,pause_times[i]); total_time += pause_times[i] * i; n += pause_times[i]; if (i > mid) right += pause_times[i]; while(right > left) { left += pause_times[mid++]; right -= pause_times[mid]; } } } printf("Number of collections: %d\r\n",n); printf("Total collection time: %d\r\n",total_time); if (n > 0) printf("Mean pause time: %d\r\n",total_time / n); printf("Geometrical mean: %d\r\n",mid); total_time = 0; n = 0; left = 0; right = 0; mid = 0; printf("Pause times in major collection:\r\n"); for (i = 0; i < MAX_PAUSE_TIME; i++) { if (pause_times_old[i] > 0) { printf("%d: %ld\r\n",i,pause_times_old[i]); total_time += pause_times_old[i] * i; n += pause_times_old[i]; } } printf("Number of collections: %d\r\n",n); printf("Total collection time: %d\r\n",total_time); if (n > 0) printf("Mean pause time: %d\r\n",total_time / n); BIF_RET(am_true);#else BIF_RET(am_false);#endif}#ifdef BM_TIMERS#if USE_PERFCTR#define MAKE_TIME(_timer_) { \ BM_TIMER_T tmp = _timer_##_time; \ milli = (uint)(tmp - ((int)(tmp / 1000)) * 1000); \ tmp /= 1000; \ sec = (uint)(tmp - ((int)(tmp / 60)) * 60); \ min = (uint)tmp / 60; }#define MAKE_MICRO_TIME(_timer_) { \ BM_TIMER_T tmp = _timer_##_time * 1000; \ micro = (uint)(tmp - ((int)(tmp / 1000)) * 1000); \ tmp /= 1000; \ milli = (uint)(tmp - ((int)(tmp / 1000)) * 1000); \ sec = (uint)tmp / 1000; }#else#define MAKE_TIME(_timer_) { \ BM_TIMER_T tmp = _timer_##_time / 1000000; \ milli = tmp % 1000; \ tmp /= 1000; \ sec = tmp % 60; \ min = tmp / 60; }#define MAKE_MICRO_TIME(_timer_) { \ BM_TIMER_T tmp = _timer_##_time / 1000; \ micro = tmp % 1000; \ tmp /= 1000; \ milli = tmp % 1000; \ sec = tmp / 1000; }#endif#else#define MAKE_TIME(_timer_)#define MAKE_MICRO_TIME(_timer_)#endifBIF_RETTYPE hipe_bifs_system_timer_0(BIF_ALIST_0){#ifdef __BENCHMARK__ uint min = 0; uint sec = 0; uint milli = 0; Eterm *hp; hp = HAlloc(BIF_P, 4); MAKE_TIME(system); BIF_RET(TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_system_timer_clear_0(BIF_ALIST_0){#ifdef BM_TIMERS system_time = 0; BIF_RET(am_true);#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_send_timer_0(BIF_ALIST_0){#ifdef __BENCHMARK__ uint min = 0; uint sec = 0; uint milli = 0; Eterm *hp; Eterm sendtime, copytime, sizetime; hp = HAlloc(BIF_P, 4 * 4); MAKE_TIME(send); sendtime = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_TIME(copy); copytime = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_TIME(size); sizetime = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; BIF_RET(TUPLE3(hp,sendtime,copytime,sizetime));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_send_timer_clear_0(BIF_ALIST_0){#ifdef BM_TIMERS send_time = 0; copy_time = 0; size_time = 0; BIF_RET(am_true);#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_gc_timer_0(BIF_ALIST_0){#ifdef __BENCHMARK__ Eterm *hp; uint min = 0; uint sec = 0; uint milli = 0; uint micro = 0; Eterm minor, major, max_min, max_maj; hp = HAlloc(BIF_P, 4 * 4 + 5); MAKE_TIME(minor_gc); minor = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_TIME(major_gc); major = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_MICRO_TIME(max_minor); max_min = TUPLE3(hp,make_small(sec), make_small(milli), make_small(micro)); hp += 4; MAKE_MICRO_TIME(max_major); max_maj = TUPLE3(hp,make_small(sec), make_small(milli), make_small(micro)); hp += 4; BIF_RET(TUPLE4(hp,minor,major,max_min,max_maj));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_shared_gc_timer_0(BIF_ALIST_0){#ifdef __BENCHMARK__ Eterm *hp; uint min = 0; uint sec = 0; uint milli = 0; uint micro = 0; Eterm minor, major, max_min, max_maj; hp = HAlloc(BIF_P, 4 * 4 + 5); MAKE_TIME(minor_global_gc); minor = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_TIME(major_global_gc); major = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_MICRO_TIME(max_global_minor); max_min = TUPLE3(hp,make_small(sec), make_small(milli), make_small(micro)); hp += 4; MAKE_MICRO_TIME(max_global_major); max_maj = TUPLE3(hp,make_small(sec), make_small(milli), make_small(micro)); hp += 4; BIF_RET(TUPLE4(hp,minor,major,max_min,max_maj));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_gc_timer_clear_0(BIF_ALIST_0){#ifdef BM_TIMERS minor_gc_time = 0; major_gc_time = 0; max_minor_time = 0; max_major_time = 0; minor_global_gc_time = 0; major_global_gc_time = 0; max_global_minor_time = 0; max_global_major_time = 0; BIF_RET(am_true);#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_misc_timer_0(BIF_ALIST_0){#ifdef __BENCHMARK__ uint min = 0; uint sec = 0; uint milli = 0; Eterm *hp; Eterm misctime1, misctime2, misctime3; hp = HAlloc(BIF_P, 4 * 4); MAKE_TIME(misc0); misctime1 = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_TIME(misc1); misctime2 = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; MAKE_TIME(misc2); misctime3 = TUPLE3(hp,make_small(min), make_small(sec), make_small(milli)); hp += 4; BIF_RET(TUPLE3(hp,misctime1,misctime2,misctime3));#else BIF_RET(am_false);#endif}BIF_RETTYPE hipe_bifs_misc_timer_clear_0(BIF_ALIST_0){#ifdef BM_TIMERS misc0_time = 0; misc1_time = 0; misc2_time = 0; BIF_RET(am_true);#else BIF_RET(am_false);#endif}#undef MAKE_TIME#undef MAKE_MICRO_TIME/* * HiPE hrvtime(). * These implementations are currently available: * + On Linux with the perfctr extension we can use the process' * virtualised time-stamp counter. To enable this mode you must * pass `--with-perfctr=/path/to/perfctr' when configuring. * + The fallback, which is the same as {X,_} = runtime(statistics). */#if USE_PERFCTR#include "hipe_perfctr.h"static int hrvtime_is_open;#define hrvtime_is_started() hrvtime_is_openstatic void start_hrvtime(void){ if (hipe_perfctr_hrvtime_open() >= 0) hrvtime_is_open = 1;}#define get_hrvtime() hipe_perfctr_hrvtime_get()#define stop_hrvtime() hipe_perfctr_hrvtime_close()#else/* * Fallback, if nothing better exists. * This is the same as {X,_} = statistics(runtime), which uses * times(2) on Unix systems. */#define hrvtime_is_started() 1#define start_hrvtime() do{}while(0)#define stop_hrvtime() do{}while(0)static double get_hrvtime(void){ unsigned long ms_user; elapsed_time_both(&ms_user, NULL, NULL, NULL); return (double)ms_user;}#endif /* hrvtime support */BIF_RETTYPE hipe_bifs_get_hrvtime_0(BIF_ALIST_0){ Eterm *hp; Eterm res; FloatDef f; if (!hrvtime_is_started()) { start_hrvtime(); if (!hrvtime_is_started()) BIF_RET(NIL); /* arity 0 BIFs may not fail */ } f.fd = get_hrvtime(); hp = HAlloc(BIF_P, FLOAT_SIZE_OBJECT); res = make_float(hp); PUT_DOUBLE(f, hp); BIF_RET(res);}BIF_RETTYPE hipe_bifs_stop_hrvtime_0(BIF_ALIST_0){ stop_hrvtime(); BIF_RET(am_true);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?