mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-11-04 03:58:27 +00:00 
			
		
		
		
	stats: Add igt_stats_get_range()
Somewhat useful, for instance to size an histogram. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
		
							parent
							
								
									4a89a841a1
								
							
						
					
					
						commit
						0e4c175e04
					
				@ -187,6 +187,22 @@ uint64_t igt_stats_get_max(igt_stats_t *stats)
 | 
				
			|||||||
	return stats->max;
 | 
						return stats->max;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * igt_stats_get_range:
 | 
				
			||||||
 | 
					 * @stats: An #igt_stats_t instance
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Retrieves the range of the values in @stats. The range is the difference
 | 
				
			||||||
 | 
					 * between the highest and the lowest value.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * The range can be a deceiving characterization of the values, because there
 | 
				
			||||||
 | 
					 * can be extreme minimal and maximum values that are just anomalies. Prefer
 | 
				
			||||||
 | 
					 * the interquatile range or an histogram.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					uint64_t igt_stats_get_range(igt_stats_t *stats)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return igt_stats_get_max(stats) - igt_stats_get_min(stats);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Algorithm popularised by Knuth in:
 | 
					 * Algorithm popularised by Knuth in:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 | 
				
			|||||||
@ -52,6 +52,7 @@ void igt_stats_set_population(igt_stats_t *stats, bool full_population);
 | 
				
			|||||||
void igt_stats_push(igt_stats_t *stats, uint64_t value);
 | 
					void igt_stats_push(igt_stats_t *stats, uint64_t value);
 | 
				
			||||||
uint64_t igt_stats_get_min(igt_stats_t *stats);
 | 
					uint64_t igt_stats_get_min(igt_stats_t *stats);
 | 
				
			||||||
uint64_t igt_stats_get_max(igt_stats_t *stats);
 | 
					uint64_t igt_stats_get_max(igt_stats_t *stats);
 | 
				
			||||||
 | 
					uint64_t igt_stats_get_range(igt_stats_t *stats);
 | 
				
			||||||
double igt_stats_get_mean(igt_stats_t *stats);
 | 
					double igt_stats_get_mean(igt_stats_t *stats);
 | 
				
			||||||
double igt_stats_get_variance(igt_stats_t *stats);
 | 
					double igt_stats_get_variance(igt_stats_t *stats);
 | 
				
			||||||
double igt_stats_get_std_deviation(igt_stats_t *stats);
 | 
					double igt_stats_get_std_deviation(igt_stats_t *stats);
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,16 @@ static void test_min_max(void)
 | 
				
			|||||||
	igt_assert(igt_stats_get_max(&stats) == 10);
 | 
						igt_assert(igt_stats_get_max(&stats) == 10);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void test_range(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						igt_stats_t stats;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						igt_stats_init(&stats, 5);
 | 
				
			||||||
 | 
						push_fixture_1(&stats);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						igt_assert(igt_stats_get_range(&stats) == 8);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void test_mean(void)
 | 
					static void test_mean(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	igt_stats_t stats;
 | 
						igt_stats_t stats;
 | 
				
			||||||
@ -139,6 +149,7 @@ igt_simple_main
 | 
				
			|||||||
	test_init_zero();
 | 
						test_init_zero();
 | 
				
			||||||
	test_init();
 | 
						test_init();
 | 
				
			||||||
	test_min_max();
 | 
						test_min_max();
 | 
				
			||||||
 | 
						test_range();
 | 
				
			||||||
	test_mean();
 | 
						test_mean();
 | 
				
			||||||
	test_invalidate_mean();
 | 
						test_invalidate_mean();
 | 
				
			||||||
	test_std_deviation();
 | 
						test_std_deviation();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user