]> sourceware.org Git - systemtap.git/commitdiff
2007-04-05 Martin Hunt <hunt@redhat.com>
authorhunt <hunt>
Thu, 5 Apr 2007 18:50:54 +0000 (18:50 +0000)
committerhunt <hunt>
Thu, 5 Apr 2007 18:50:54 +0000 (18:50 +0000)
* bench2/bench.rb (Stapbench::run): Check result code
of "killall staprun". If it is nonzero, something happened to
staprun. Print an error.
(Stapbench::load): Define STP_NO_OVERLOAD.
* bench2/README: Update.
* bench2/print_bench: New set of tests.

runtime/bench2/README
runtime/bench2/bench.rb
runtime/bench2/print_bench [new file with mode: 0755]

index 6bbf26040340f3d52644e8081d9001b0e0a109af..5a6ce30241e2d2f72b5cce5f8282cc030b1c669d 100644 (file)
@@ -1,19 +1,71 @@
 This is a framework for profiling systemtap scripts and the
 underlying runtime functions.
 
-To try the tests:
->make
+To try the tests, first build the "itest" driver.
+> make
+
+Then try out some of the example tests.
 ./run_bench
 ./stap_bench
+./print_bench
 
 You will need ruby installed. "yum install ruby" or "up2date ruby" to get it.
 
 
+HOW IT WORKS
+
+"itest"  by default calls getuid() 2 million times and
+reports the time in nanoseconds per call. It can divide the work 
+across a number of threads if requested.
+
+> ./itest --help
+Usage ./itest [num_threads] [total_iterations]
+./itest will call sys_getuid() total_iterations [default 2,000,000]
+times divided across num_threads [default 1].
+
+getuid() is used because it is an existing system call with very little
+overhead and is not often used. Any background calls going on in the system
+will not have measurable impact compared to the millions of calls from itest.
+
+bench.rb is a Ruby test class that runs itest without any kprobes then with kprobes.
+It reports on the additional overhead it measures.
+
+To create a test object, you do either
+>test = Bench.new("description") OR
+>test = Stapbench.new("description")
+
+"test" is a variable name that will be your object.
+
+"Bench" is a class for raw kprobes. It is useful for measuring 
+runtime function performance or kprobe overhead.
+
+"Stapbench" is a systemtap test class. You probably want to use it.
+
+Next, give the class some code. This is the code that will be executed 
+every time sys_getuid() is hit. 
+
+>test.code = 'printf("Hello World\n")'
+
+Then run it and print the results.
+>test.run
+>test.print
+
+There are some options. Set these before running the test.
+
+>test.outfile="/dev/null"
+This will write discard any output. This is useful to measure the
+transport performance because output goes to userspace but is not
+written to disk.
+
+> test.trans=BULK
+Use bulk transport.  Default is STREAM
+
 ---- FILES ----
 a.st - sample script test file
 b.st - sample script test file
 
 itest.c - used by tests. Type "make" to build
+
 Makefile - makefile for itest
 
 run_bench - test driver with some test scripts. Tests may
index a04582d2f2cd024da89c8c467b65a955c6687fa2..cde93245bdf57bb8c6ab3612abdff75972e5f28e 100644 (file)
@@ -265,6 +265,10 @@ class Stapbench < Bench
       sum=0
       `./itest #{threads} > bench`
       `sudo killall -HUP staprun`
+      if ($? != 0)
+       puts "status=#{$?}"
+       system("tail xxx.out")
+      end
       Process.wait     # wait for staprun to exit
       @results[threads] = `cat bench`.split[0].to_i - @@ftime[threads]
       File.open("xxx.out") do |file|
@@ -283,10 +287,10 @@ class Stapbench < Bench
   protected
 
   def load
-    args = "-vv"
-    if @trans == BULK then args = "-bvv" end
+    args = "-vv -DSTP_NO_OVERLOAD"
+    if @trans == BULK then args = "-bvv -DSTP_NO_OVERLOAD" end
     fork do exec "stap #{args} -o #{@outfile} bench.stp &> xxx.out" end
-    sleep 10
+    sleep 30
   end
   
   def compile
diff --git a/runtime/bench2/print_bench b/runtime/bench2/print_bench
new file mode 100755 (executable)
index 0000000..a2a9c40
--- /dev/null
@@ -0,0 +1,68 @@
+#!/usr/bin/env ruby
+load './bench.rb'
+
+# script test with empty probe
+test0 = Stapbench.new("empty probe")
+test0.code = ""
+test0.run
+test0.print
+
+# script test to printf 100 chars
+test2 = Stapbench.new("printf 100 chars")
+test2.code = 'printf("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n")'
+test2.outfile="/dev/null"
+test2.run
+test2.print
+test2.trans=BULK
+test2.run
+test2.print
+
+# script test to print 100 chars
+test3 = Stapbench.new("print 100 chars")
+test3.code = "print(\"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\n\")"
+test3.outfile="/dev/null"
+test3.run
+test3.print
+test3.trans=BULK
+test3.run
+test3.print
+
+# script test to print 100 chars, 1 at a time
+test3a = Stapbench.new("print 100 chars, 1 at a time")
+test3a.code = "for (i=0; i < 100; i++) print(\"x\")"
+test3a.outfile="/dev/null"
+test3a.run
+test3a.print
+test3a.trans=BULK
+test3a.run
+test3a.print
+
+# script test to print 100 different chars, 1 at a time, using print_char
+test3b = Stapbench.new("print 100 different chars, 1 at a time, using print_char")
+test3b.code = "for (i = 0; i < 99; i++) print_char(i+32); print_char(10)"
+test3b.outfile="/dev/null"
+test3b.run
+test3b.print
+test3b.trans=BULK
+test3b.run
+test3b.print
+
+# script test to binary print 4 integers
+test4 = Stapbench.new("binary printf 4 integers (%b)")
+test4.code = "printf(\"%b%b%b%b\", 111,22,333,444)"
+test4.outfile="/dev/null"
+test4.run
+test4.print
+test4.trans = BULK
+test4.run
+test4.print
+
+# script test to binary print 4 integers
+test5 = Stapbench.new("_stp_print_binary 4 integers")
+test5.code = "stp_print_binary(4,111,22,333,444)"
+test5.outfile="/dev/null"
+test5.run
+test5.print
+test5.trans = BULK
+test5.run
+test5.print
This page took 0.030286 seconds and 5 git commands to generate.