mirror of
https://bitbucket.org/Mattrixwv/myhelpers.git
synced 2025-12-06 18:43:59 -05:00
59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
//Programs/C/myHelpers/testStopwatch.c
|
|
//Matthew Ellison
|
|
// Created: 03-08-19
|
|
//Modified: 03-08-19
|
|
//This program is a simple test for the stopwatch struct and accompanying functions
|
|
/*
|
|
Copyright (C) 2019 Matthew Ellison
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <inttypes.h>
|
|
#include "Stopwatch.h"
|
|
|
|
const int NUM_OF_RUNS = 10000;
|
|
|
|
|
|
int main(){
|
|
struct Stopwatch timer;
|
|
init(&timer);
|
|
start(&timer);
|
|
for(int cnt = 0;cnt < NUM_OF_RUNS;++cnt){
|
|
printf("%d\n", cnt);
|
|
}
|
|
stop(&timer);
|
|
printf("It took %d nanoseconds to run this program\n", getNano(&timer));
|
|
printf("It took %f microseconds to run this program\n", getMicro(&timer));
|
|
printf("It took %f milliseconds to run this program\n", getMilli(&timer));
|
|
printf("It took %f seconds to run this program\n", getSecond(&timer));
|
|
printf("It took %f minutes to run this program\n", getMinute(&timer));
|
|
printf("It took %f hours to run this program\n", getHour(&timer));
|
|
printf("It took %s to run this program\n", getStr(&timer));
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Results:
|
|
It took 1289000000 nanoseconds to run this program
|
|
It took 1289000.000000 microseconds to run this program
|
|
It took 1289.000000 milliseconds to run this program
|
|
It took 1.289000 seconds to run this program
|
|
It took 0.021483 minutes to run this program
|
|
It took 0.003581 hours to run this program
|
|
It took 1.288 seconds to run this program
|
|
*/
|