mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	tests: add noop to fixed-benchmark
I was just curious of how much the looping takes time without conversion, so I added this. My results on Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz: benchmarked noop: 1.876349827s benchmarked magic: 2.245844470s benchmarked div: 12.709085309s benchmarked mul: 7.504838141s Mul seems to take 15x the time magic does, cool! Btw. the simple default cast of int32_t to double is slower than magic for me, hence the use of union. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
		
							parent
							
								
									f5df38959b
								
							
						
					
					
						commit
						32ec041333
					
				
					 1 changed files with 16 additions and 0 deletions
				
			
		| 
						 | 
					@ -29,6 +29,21 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
volatile double global_d;
 | 
					volatile double global_d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					noop_conversion(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						wl_fixed_t f;
 | 
				
			||||||
 | 
						union {
 | 
				
			||||||
 | 
							int64_t i;
 | 
				
			||||||
 | 
							double d;
 | 
				
			||||||
 | 
						} u;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (f = 0; f < INT32_MAX; f++) {
 | 
				
			||||||
 | 
							u.i = f;
 | 
				
			||||||
 | 
							global_d = u.d;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
magic_conversion(void)
 | 
					magic_conversion(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -80,6 +95,7 @@ benchmark(const char *s, void (*f)(void))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[])
 | 
					int main(int argc, char *argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						benchmark("noop", noop_conversion);
 | 
				
			||||||
	benchmark("magic", magic_conversion);
 | 
						benchmark("magic", magic_conversion);
 | 
				
			||||||
	benchmark("div", div_conversion);
 | 
						benchmark("div", div_conversion);
 | 
				
			||||||
	benchmark("mul", mul_conversion);
 | 
						benchmark("mul", mul_conversion);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue