Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
55629e0a
Commit
55629e0a
authored
7 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
sys: added simple benchmark module
parent
197abe8b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile.dep
+4
-0
4 additions, 0 deletions
Makefile.dep
sys/benchmark/Makefile
+1
-0
1 addition, 0 deletions
sys/benchmark/Makefile
sys/benchmark/benchmark.c
+32
-0
32 additions, 0 deletions
sys/benchmark/benchmark.c
sys/include/benchmark.h
+76
-0
76 additions, 0 deletions
sys/include/benchmark.h
with
113 additions
and
0 deletions
Makefile.dep
+
4
−
0
View file @
55629e0a
...
@@ -679,6 +679,10 @@ ifneq (,$(filter fatfs_vfs,$(USEMODULE)))
...
@@ -679,6 +679,10 @@ ifneq (,$(filter fatfs_vfs,$(USEMODULE)))
USEMODULE
+=
vfs
USEMODULE
+=
vfs
endif
endif
ifneq
(,$(filter benchmark,$(USEMODULE)))
USEMODULE
+=
xtimer
endif
# always select gpio (until explicit dependencies are sorted out)
# always select gpio (until explicit dependencies are sorted out)
FEATURES_OPTIONAL
+=
periph_gpio
FEATURES_OPTIONAL
+=
periph_gpio
...
...
This diff is collapsed.
Click to expand it.
sys/benchmark/Makefile
0 → 100644
+
1
−
0
View file @
55629e0a
include
$(RIOTBASE)/Makefile.base
This diff is collapsed.
Click to expand it.
sys/benchmark/benchmark.c
0 → 100644
+
32
−
0
View file @
55629e0a
/*
* Copyright (C) 2017 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
"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
))
/
(
runs
/
1000
);
printf
(
"%11s: %9"
PRIu32
"us --- %2"
PRIu32
".%03"
PRIu32
"us per call
\n
"
,
name
,
time
,
full
,
div
);
}
This diff is collapsed.
Click to expand it.
sys/include/benchmark.h
0 → 100644
+
76
−
0
View file @
55629e0a
/*
* Copyright (C) 2017 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.
*/
/**
* @defgroup sys_benchmark Benchmark
* @ingroup sys
* @brief Framework for running simple runtime benchmarks
* @{
*
* @file
* @brief Interface for running simple benchmarks
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef BENCHMARK_H
#define BENCHMARK_H
#include
<stdint.h>
#include
"xtimer.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* @brief Prepare the current scope for running BENCHMARK_x() macros
*/
#define BENCHMARK_SETUP() \
unsigned state; \
unsigned time
/**
* @brief Measure the runtime of a given function call
*
* As we are doing a time sensitive measurement here, there is no way around
* using a preprocessor function, as going with a function pointer or similar
* would influence the measured runtime...
*
* @note BENCHMARK_SETUP() needs to be called in the same scope
*
* @param[in] name name for labeling the output
* @param[in] runs number of times to run @p func
* @param[in] func function call to benchmark
*/
#define BENCHMARK_FUNC(name, runs, func) \
state = irq_disable(); \
time = xtimer_now_usec(); \
for (unsigned long i = 0; i < runs; i++) { \
func; \
} \
time = (xtimer_now_usec() - time); \
irq_restore(state); \
benchmark_print_time(time, runs, name)
/**
* @brief Output the given time as well as the time per run on STDIO
*
* @param[in] time overall runtime in us
* @param[in] runs number of runs
* @param[in] name name to label the output
*/
void
benchmark_print_time
(
uint32_t
time
,
unsigned
long
runs
,
const
char
*
name
);
#ifdef __cplusplus
}
#endif
#endif
/* BENCHMARK_H */
/** @} */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment