Sha256: b596cca6b5039c359e92a089a0eaa44ba0fe4c314e7755ac643b772c6cc58f2e

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'ruby-prof'
require 'test_helper'
require 'prime'


# --  Tests ----
class ClockModeTest < Test::Unit::TestCase
  def test_clock
    return
    RubyProf::clock_mode = RubyProf::PROCESS_TIME
    assert_equal(RubyProf::PROCESS_TIME, RubyProf::clock_mode)
    result = RubyProf.profile do
			run_primes
		end
		
		print_results(result)
    
    result.threads.values.each do |methods|
			methods.values.each do |method|
    		check_parent_times(method)
    		check_parent_calls(method)
    		check_child_times(method)		
			end
  	end
  end
  
  def test_gettimeofday
    return
    RubyProf::clock_mode = RubyProf::WALL_TIME
    assert_equal(RubyProf::WALL_TIME, RubyProf::clock_mode)
    result = RubyProf.profile do
			run_primes
		end
    
		print_results(result)
		
    result.threads.values.each do |methods|
			methods.values.each do |method|
    		check_parent_times(method)
    		check_parent_calls(method)
    		check_child_times(method)		
			end
  	end
  end
  
  def test_cpu
    #return
    RubyProf::clock_mode = RubyProf::CPU_TIME
    assert_equal(RubyProf::CPU, RubyProf::clock_mode)
    result = RubyProf.profile do
			run_primes
		end
    
		print_results(result)
		
    result.threads.values.each do |methods|
			methods.values.each do |method|
    		check_parent_times(method)
    		check_parent_calls(method)
    		check_child_times(method)		
			end
  	end
  end
  
  def test_invalid
    assert_raise(ArgumentError) do
    	RubyProf::clock_mode = 7777
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-prof-0.4.0-mswin32 test/clock_mode_test.rb
ruby-prof-0.4.0 test/clock_mode_test.rb