blob: 43a4f3f8d0b253b418a65f8da1631aaa0cf57a0d [file] [log] [blame]
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -07001#!/usr/bin/python
2# Copyright (c) PLUMgrid, Inc.
3# Licensed under the Apache License, Version 2.0 (the "License")
4
Brenden Blancoc35989d2015-09-02 18:04:07 -07005from bcc import BPF
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -07006from time import sleep
7
8b = BPF(src_file="task_switch.c")
Brenden Blanco5eef65e2015-08-19 15:39:19 -07009b.attach_kprobe(event="finish_task_switch", fn_name="count_sched")
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -070010
11# generate many schedule events
12for i in range(0, 100): sleep(0.01)
13
Brenden Blancoc8b66982015-08-28 23:15:19 -070014for k, v in b["stats"].items():
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -070015 print("task_switch[%5d->%5d]=%u" % (k.prev_pid, k.curr_pid, v.value))