libbb: introduce and use monotonic_ms
function old new delta monotonic_ms - 60 +60 process_stdin 433 443 +10 display_speed 85 90 +5 nmeter_main 672 674 +2 builtin_type 114 116 +2 bb__parsespent 117 119 +2 ifplugd_main 1110 1109 -1 acpid_main 441 440 -1 chat_main 1361 1359 -2 doCommands 2458 2449 -9 arpping 466 450 -16 run_command 268 234 -34 readcmd 1072 1034 -38 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/7 up/down: 81/-101) Total: -20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
		
							
								
								
									
										12
									
								
								libbb/time.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								libbb/time.c
									
									
									
									
									
								
							@@ -175,6 +175,12 @@ unsigned long long FAST_FUNC monotonic_us(void)
 | 
			
		||||
	get_mono(&ts);
 | 
			
		||||
	return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000;
 | 
			
		||||
}
 | 
			
		||||
unsigned long long FAST_FUNC monotonic_ms(void)
 | 
			
		||||
{
 | 
			
		||||
	struct timespec ts;
 | 
			
		||||
	get_mono(&ts);
 | 
			
		||||
	return ts.tv_sec * 1000ULL + ts.tv_nsec/1000000;
 | 
			
		||||
}
 | 
			
		||||
unsigned FAST_FUNC monotonic_sec(void)
 | 
			
		||||
{
 | 
			
		||||
	struct timespec ts;
 | 
			
		||||
@@ -196,6 +202,12 @@ unsigned long long FAST_FUNC monotonic_us(void)
 | 
			
		||||
	gettimeofday(&tv, NULL);
 | 
			
		||||
	return tv.tv_sec * 1000000ULL + tv.tv_usec;
 | 
			
		||||
}
 | 
			
		||||
unsigned long long FAST_FUNC monotonic_ms(void)
 | 
			
		||||
{
 | 
			
		||||
	struct timeval tv;
 | 
			
		||||
	gettimeofday(&tv, NULL);
 | 
			
		||||
	return tv.tv_sec * 1000ULL + tv.tv_usec / 1000;
 | 
			
		||||
}
 | 
			
		||||
unsigned FAST_FUNC monotonic_sec(void)
 | 
			
		||||
{
 | 
			
		||||
	return time(NULL);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user