mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
5833bcb7ba
If runs < 1000, `runs / 1000` will result in 0 - which causes a division by 0.
38 lines
924 B
C
38 lines
924 B
C
/*
|
|
* Copyright (C) 2017,2018 Freie Universität Berlin
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
* Public License v2.1. See the file LICENSE in the top level directory for more
|
|
* details.
|
|
*/
|
|
|
|
/**
|
|
* @ingroup sys_benchmark
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief Utility functions for the benchmark module
|
|
*
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
|
*
|
|
* @}
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "timex.h"
|
|
|
|
#include "benchmark.h"
|
|
|
|
void benchmark_print_time(uint32_t time, unsigned long runs, const char *name)
|
|
{
|
|
uint32_t full = (time / runs);
|
|
uint32_t div = (time - (full * runs)) * 1000 / runs;
|
|
|
|
uint32_t per_sec = (uint32_t)(((uint64_t)US_PER_SEC * runs) / time);
|
|
|
|
printf("%25s: %9" PRIu32 "us"
|
|
" --- %2" PRIu32 ".%03" PRIu32 "us per call"
|
|
" --- %9" PRIu32 " calls per sec\n",
|
|
name, time, full, div, per_sec);
|
|
}
|