drm/bridge: adv7511: Switch to atomic operations
[drm/drm-misc.git] / tools / testing / selftests / damon / access_memory.c
blob56b17e8fe1be83fe0bdfc7b18a4126cb8fe04f6a
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Artificial memory access program for testing DAMON.
4 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <time.h>
11 int main(int argc, char *argv[])
13 char **regions;
14 clock_t start_clock;
15 int nr_regions;
16 int sz_region;
17 int access_time_ms;
18 int i;
20 if (argc != 4) {
21 printf("Usage: %s <number> <size (bytes)> <time (ms)>\n",
22 argv[0]);
23 return -1;
26 nr_regions = atoi(argv[1]);
27 sz_region = atoi(argv[2]);
28 access_time_ms = atoi(argv[3]);
30 regions = malloc(sizeof(*regions) * nr_regions);
31 for (i = 0; i < nr_regions; i++)
32 regions[i] = malloc(sz_region);
34 for (i = 0; i < nr_regions; i++) {
35 start_clock = clock();
36 while ((clock() - start_clock) * 1000 / CLOCKS_PER_SEC <
37 access_time_ms)
38 memset(regions[i], i, sz_region);
40 return 0;