Lines Matching +full:1 +full:br +full:- +full:100
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
9 * 1. Redistributions of source code must retain the above copyright
78 mib[1] = KERN_CLOCKRATE; in getstathz()
80 if (sysctl(mib, 2, &clockrate, &size, NULL, 0) == -1) in getstathz()
81 err(1, "sysctl kern.clockrate"); in getstathz()
89 #define INST 1
90 #define BR 2 macro
91 #define IAP_START BR
99 "branch-misses",
100 "cache-references",
101 "cache-misses",
106 "unhalted-cycles",
109 "branch-mispredicts",
110 "LLC-REFERENCE",
111 "LLC-MISSES",
121 "\t -j <eventlist>, --events <eventlist> comma-delimited list of event specifiers\n" in usage()
133 decimal_point = localeconv()->decimal_point[0]; in showtime()
135 after->tv_sec -= before->tv_sec; in showtime()
136 after->tv_nsec -= before->tv_nsec; in showtime()
137 if (after->tv_nsec < 0) { in showtime()
138 after->tv_sec--; in showtime()
139 after->tv_nsec += 1000000000; in showtime()
142 real = (after->tv_sec * 1000000000 + after->tv_nsec) / 1000; in showtime()
143 user = ru->ru_utime.tv_sec * 1000000 + ru->ru_utime.tv_usec; in showtime()
144 sys = ru->ru_stime.tv_sec * 1000000 + ru->ru_stime.tv_usec; in showtime()
146 (intmax_t)after->tv_sec, decimal_point, in showtime()
147 after->tv_nsec / 10000000, 100 * (double)(sys + user + 1) / (double)(real + 1)); in showtime()
149 (intmax_t)ru->ru_utime.tv_sec, decimal_point, in showtime()
150 ru->ru_utime.tv_usec / 10000, 100 * (double)(user + 1) / (double)(real + 1)); in showtime()
152 (intmax_t)ru->ru_stime.tv_sec, decimal_point, in showtime()
153 ru->ru_stime.tv_usec / 10000, 100 * (double)(sys + 1) / (double)(real + 1)); in showtime()
168 if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1, in pmc_stat_setup_stat()
169 sizeof(rootmask), &rootmask) == -1) in pmc_stat_setup_stat()
184 newcnt < STAT_MODE_NPMCS - IAP_START) { in pmc_stat_setup_stat()
189 start = IAP_START + STAT_MODE_NPMCS - FIXED_MODE_NPMCS - newcnt; in pmc_stat_setup_stat()
210 ev->ev_mode = PMC_MODE_SC; in pmc_stat_setup_stat()
212 ev->ev_mode = PMC_MODE_TC; in pmc_stat_setup_stat()
213 ev->ev_spec = strdup(stat_mode_cntrs[i]); in pmc_stat_setup_stat()
214 if (ev->ev_spec == NULL) in pmc_stat_setup_stat()
217 ev->ev_name = malloc(c + 1); in pmc_stat_setup_stat()
218 if (ev->ev_name == NULL) in pmc_stat_setup_stat()
220 (void)strncpy(ev->ev_name, stat_mode_cntrs[i], c); in pmc_stat_setup_stat()
221 *(ev->ev_name + c) = '\0'; in pmc_stat_setup_stat()
223 ev->ev_count = -1; in pmc_stat_setup_stat()
224 ev->ev_flags = 0; in pmc_stat_setup_stat()
225 ev->ev_flags |= PMC_F_DESCENDANTS; in pmc_stat_setup_stat()
226 ev->ev_cumulative = 1; in pmc_stat_setup_stat()
228 ev->ev_saved = 0LL; in pmc_stat_setup_stat()
229 ev->ev_pmcid = PMC_ID_INVALID; in pmc_stat_setup_stat()
232 ev->ev_cpu = CPU_FFS(&cpumask) - 1; in pmc_stat_setup_stat()
233 CPU_CLR(ev->ev_cpu, &cpumask); in pmc_stat_setup_stat()
235 CPU_SET(ev->ev_cpu, &cpumask); in pmc_stat_setup_stat()
237 ev->ev_cpu = PMC_CPU_ANY; in pmc_stat_setup_stat()
241 err(1, "clock_gettime"); in pmc_stat_setup_stat()
255 ticks = hz * (ru->ru_utime.tv_sec + ru->ru_stime.tv_sec) + in pmc_stat_print_stat()
256 hz * (ru->ru_utime.tv_usec + ru->ru_stime.tv_usec) / 1000000; in pmc_stat_print_stat()
258 err(1, "clock_gettime"); in pmc_stat_print_stat()
260 * If our round-off on the tick calculation still puts us at 0, in pmc_stat_print_stat()
264 ticks = 1; in pmc_stat_print_stat()
266 ru->ru_minflt, "page faults", ((double)ru->ru_minflt / (double)ticks) / hz); in pmc_stat_print_stat()
268 ru->ru_nvcsw, "voluntary csw", ((double)ru->ru_nvcsw / (double)ticks) / hz); in pmc_stat_print_stat()
270 ru->ru_nivcsw, "involuntary csw", ((double)ru->ru_nivcsw / (double)ticks) / hz); in pmc_stat_print_stat()
275 if (pmc_read(ev->ev_pmcid, &value) < 0) in pmc_stat_print_stat()
277 ev->ev_name); in pmc_stat_print_stat()
279 if (strcmp(ev->ev_name, stat_mode_cntrs[i]) == 0) in pmc_stat_print_stat()
286 fprintf(pmc_args.pa_printfile, "%16jd %s\n", (uintmax_t)cvals[BR], stat_mode_names[BR]); in pmc_stat_print_stat()
290 100 * ((double)cvals[BR_MISS] / cvals[BR])); in pmc_stat_print_stat()
303 100 * ((double)cvals[CACHE_MISS] / cvals[CACHE])); in pmc_stat_print_stat()
328 while ((option = getopt_long(argc, argv, "dj:", longopts, NULL)) != -1) { in pmc_stat_internal()
334 do_debug = 1; in pmc_stat_internal()
341 pmc_args.pa_argc = (argc -= optind); in pmc_stat_internal()
350 if (kevent(pmc_kq, &kev, 1, NULL, 0, NULL) < 0) in pmc_stat_internal()
354 if (kevent(pmc_kq, &kev, 1, NULL, 0, NULL) < 0) in pmc_stat_internal()
357 if (kevent(pmc_kq, &kev, 1, NULL, 0, NULL) < 0) in pmc_stat_internal()
362 if (pmc_allocate(ev->ev_spec, ev->ev_mode, in pmc_stat_internal()
363 ev->ev_flags, ev->ev_cpu, &ev->ev_pmcid, ev->ev_count) < 0) in pmc_stat_internal()
365 "ERROR: Cannot allocate %s-mode pmc with specification \"%s\"", in pmc_stat_internal()
366 PMC_IS_SYSTEM_MODE(ev->ev_mode) ? in pmc_stat_internal()
367 "system" : "process", ev->ev_spec); in pmc_stat_internal()
369 if (PMC_IS_SAMPLING_MODE(ev->ev_mode) && in pmc_stat_internal()
370 pmc_set(ev->ev_pmcid, ev->ev_count) < 0) in pmc_stat_internal()
373 ev->ev_name); in pmc_stat_internal()
383 if (kevent(pmc_kq, &kev, 1, NULL, 0, NULL) < 0) in pmc_stat_internal()
414 if ((c = kevent(pmc_kq, NULL, 0, &kev, 1, NULL)) <= 0) { in pmc_stat_internal()
427 ru_valid = 1; in pmc_stat_internal()
455 ru_valid = 1; in pmc_stat_internal()
468 pmc_displayheight = ws.ws_row - 1; in pmc_stat_internal()
469 pmc_displaywidth = ws.ws_col - 1; in pmc_stat_internal()
492 return (pmc_stat_internal(argc, argv, 1)); in cmd_pmc_stat_system()