~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/bench/kallsyms-parse.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Benchmark of /proc/kallsyms parsing.
  4  *
  5  * Copyright 2020 Google LLC.
  6  */
  7 #include <stdlib.h>
  8 #include "bench.h"
  9 #include "../util/stat.h"
 10 #include <linux/time64.h>
 11 #include <subcmd/parse-options.h>
 12 #include <symbol/kallsyms.h>
 13 
 14 static unsigned int iterations = 100;
 15 
 16 static const struct option options[] = {
 17         OPT_UINTEGER('i', "iterations", &iterations,
 18                 "Number of iterations used to compute average"),
 19         OPT_END()
 20 };
 21 
 22 static const char *const bench_usage[] = {
 23         "perf bench internals kallsyms-parse <options>",
 24         NULL
 25 };
 26 
 27 static int bench_process_symbol(void *arg __maybe_unused,
 28                                 const char *name __maybe_unused,
 29                                 char type __maybe_unused,
 30                                 u64 start __maybe_unused)
 31 {
 32         return 0;
 33 }
 34 
 35 static int do_kallsyms_parse(void)
 36 {
 37         struct timeval start, end, diff;
 38         u64 runtime_us;
 39         unsigned int i;
 40         double time_average, time_stddev;
 41         int err;
 42         struct stats time_stats;
 43 
 44         init_stats(&time_stats);
 45 
 46         for (i = 0; i < iterations; i++) {
 47                 gettimeofday(&start, NULL);
 48                 err = kallsyms__parse("/proc/kallsyms", NULL,
 49                                 bench_process_symbol);
 50                 if (err)
 51                         return err;
 52 
 53                 gettimeofday(&end, NULL);
 54                 timersub(&end, &start, &diff);
 55                 runtime_us = diff.tv_sec * USEC_PER_SEC + diff.tv_usec;
 56                 update_stats(&time_stats, runtime_us);
 57         }
 58 
 59         time_average = avg_stats(&time_stats) / USEC_PER_MSEC;
 60         time_stddev = stddev_stats(&time_stats) / USEC_PER_MSEC;
 61         printf("  Average kallsyms__parse took: %.3f ms (+- %.3f ms)\n",
 62                 time_average, time_stddev);
 63         return 0;
 64 }
 65 
 66 int bench_kallsyms_parse(int argc, const char **argv)
 67 {
 68         argc = parse_options(argc, argv, options, bench_usage, 0);
 69         if (argc) {
 70                 usage_with_options(bench_usage, options);
 71                 exit(EXIT_FAILURE);
 72         }
 73 
 74         return do_kallsyms_parse();
 75 }
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php