From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14895 invoked by alias); 26 Jan 2012 21:46:32 -0000 Received: (qmail 14884 invoked by uid 22791); 26 Jan 2012 21:46:31 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Jan 2012 21:46:18 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0QLkIFZ032211 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 Jan 2012 16:46:18 -0500 Received: from cannondale.rdu.redhat.com (deploy7.rdu.redhat.com [10.11.231.236]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0QLkHnq005103; Thu, 26 Jan 2012 16:46:18 -0500 From: William Cohen To: systemtap@sourceware.org Cc: William Cohen Subject: [PATCH] Example to exercise stopwatch.stp tapset Date: Thu, 26 Jan 2012 21:46:00 -0000 Message-Id: <1327614376-1059-1-git-send-email-wcohen@redhat.com> X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2012-q1/txt/msg00046.txt.bz2 Signed-off-by: William Cohen --- .../systemtap.examples/general/stopwatches.meta | 14 +++++ .../systemtap.examples/general/stopwatches.stp | 60 ++++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-) create mode 100644 testsuite/systemtap.examples/general/stopwatches.meta create mode 100755 testsuite/systemtap.examples/general/stopwatches.stp diff --git a/testsuite/systemtap.examples/general/stopwatches.meta b/testsuite/systemtap.examples/general/stopwatches.meta new file mode 100644 index 0000000..e0b7f7c --- /dev/null +++ b/testsuite/systemtap.examples/general/stopwatches.meta @@ -0,0 +1,14 @@ +title: See the amount of wall clock time a process spends in various states +name: stopwatches.stp +version: 1.0 +author: William Cohen +keywords: time +subsystem: process +status: experimental +exit: user-controlled +output: on-exit +scope: process +description: The stopwatch.stp script illustrates how to use multiple stopwatches record how much wallclock time a process spends in kernel- and user-space. On exit the script prints out the time in seconds, milliseconds, microseconds, and nanoseconds. Note that this output of this script is not +directly comparable to the time command because time records the time that the process is actually active in kernel- and user-space. +test_check: stap -p4 stopwatches.stp +test_installcheck: stap stopwatches.stp -c "sleep 0.2" diff --git a/testsuite/systemtap.examples/general/stopwatches.stp b/testsuite/systemtap.examples/general/stopwatches.stp new file mode 100755 index 0000000..0fb2854 --- /dev/null +++ b/testsuite/systemtap.examples/general/stopwatches.stp @@ -0,0 +1,60 @@ +#! /usr/bin/env stap +# Copyright (C) 2012 Red Hat, Inc. +# by William Cohen +# +# exercise the stopwatch tapset + +global wall, system, user + + +probe begin +{ + wall = create_stopwatch(); + system = create_stopwatch(); read_stopwatch_ns(system, STOPWATCH_STOP) + user = create_stopwatch(); read_stopwatch_ns(user, STOPWATCH_STOP) +} + +probe syscall.* +{ + if (pid() != target()) next + read_stopwatch_ns(system, STOPWATCH_START) + read_stopwatch_ns(user, STOPWATCH_STOP) +} + +probe syscall.*.return +{ + if (pid() != target()) next + read_stopwatch_ns(system, STOPWATCH_STOP) + read_stopwatch_ns(user, STOPWATCH_START) +} + +probe end +{ + w = read_stopwatch_s(wall, STOPWATCH_STOP) + u = read_stopwatch_s(user, STOPWATCH_STOP) + s = read_stopwatch_s(system, STOPWATCH_STOP) + printf ("real\t%6ds\n", w); + printf ("user\t%6ds\n", u); + printf ("sys\t%6ds\n", s); + + w = read_stopwatch_ms(wall, STOPWATCH_STOP) + u = read_stopwatch_ms(user, STOPWATCH_STOP) + s = read_stopwatch_ms(system, STOPWATCH_STOP) + printf ("real\t%9dms\n", w); + printf ("user\t%9dms\n", u); + printf ("sys\t%9dms\n", s); + + w = read_stopwatch_us(wall, STOPWATCH_STOP) + u = read_stopwatch_us(user, STOPWATCH_STOP) + s = read_stopwatch_us(system, STOPWATCH_STOP) + printf ("real\t%12dus\n", w); + printf ("user\t%12dus\n", u); + printf ("sys\t%12dus\n", s); + + w = read_stopwatch_ns(wall, STOPWATCH_STOP) + u = read_stopwatch_ns(user, STOPWATCH_STOP) + s = read_stopwatch_ns(system, STOPWATCH_STOP) + printf ("real\t%15dns\n", w); + printf ("user\t%15dns\n", u); + printf ("sys\t%15dns\n", s); +} -- 1.7.1