| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/** |
| 2 |
|
|
* @file stress_set_api.cpp |
| 3 |
|
|
* @author Vincent Berenz |
| 4 |
|
|
* @license License BSD-3-Clause |
| 5 |
|
|
* @copyright Copyright (c) 2019, New York University and Max Planck |
| 6 |
|
|
* Gesellschaft. |
| 7 |
|
|
* @date 2019-05-22 |
| 8 |
|
|
* |
| 9 |
|
|
* @brief Benchmark the set method form the API |
| 10 |
|
|
*/ |
| 11 |
|
|
|
| 12 |
|
|
#include "shared_memory/benchmarks/benchmark_common.hh" |
| 13 |
|
|
#include "shared_memory/shared_memory.hpp" |
| 14 |
|
|
|
| 15 |
|
✗ |
void cleaning_memory(int) |
| 16 |
|
|
{ |
| 17 |
|
✗ |
RUNNING = false; |
| 18 |
|
✗ |
shared_memory::get_segment_mutex(SHM_NAME).unlock(); |
| 19 |
|
|
} |
| 20 |
|
|
|
| 21 |
|
✗ |
int main() |
| 22 |
|
|
{ |
| 23 |
|
|
// cleaning on ctrl+c |
| 24 |
|
|
struct sigaction cleaning; |
| 25 |
|
✗ |
cleaning.sa_handler = cleaning_memory; |
| 26 |
|
✗ |
sigemptyset(&cleaning.sa_mask); |
| 27 |
|
✗ |
cleaning.sa_flags = 0; |
| 28 |
|
✗ |
sigaction(SIGINT, &cleaning, nullptr); |
| 29 |
|
|
|
| 30 |
|
✗ |
shared_memory::clear_shared_memory(SHM_NAME); |
| 31 |
|
✗ |
shared_memory::get_segment_mutex(SHM_NAME).unlock(); |
| 32 |
|
|
|
| 33 |
|
✗ |
int count = 0; |
| 34 |
|
✗ |
RUNNING = true; |
| 35 |
|
✗ |
MeasureTime meas_time; |
| 36 |
|
✗ |
while (RUNNING && count < MAX_NUNMBER_OF_ITERATION) |
| 37 |
|
|
{ |
| 38 |
|
✗ |
shared_memory::set(SHM_NAME, SHM_OBJECT_NAME, DATA); |
| 39 |
|
|
|
| 40 |
|
✗ |
++count; |
| 41 |
|
✗ |
if (count % NUMBER_OR_MEASURED_ITERATIONS == 0) |
| 42 |
|
|
{ |
| 43 |
|
✗ |
meas_time.update(); |
| 44 |
|
✗ |
std::cout << meas_time << std::endl; |
| 45 |
|
|
} |
| 46 |
|
|
} |
| 47 |
|
|
|
| 48 |
|
✗ |
cleaning_memory(0); |
| 49 |
|
✗ |
return 0; |
| 50 |
|
|
} |
| 51 |
|
|
|