hitimes 0.3.0-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY +21 -0
 - data/LICENSE +19 -0
 - data/README +79 -0
 - data/Rakefile +63 -0
 - data/examples/benchmarks.rb +86 -0
 - data/examples/stats.rb +29 -0
 - data/ext/extconf.rb +15 -0
 - data/ext/hitimes_ext.c +20 -0
 - data/ext/hitimes_instant_clock_gettime.c +20 -0
 - data/ext/hitimes_instant_osx.c +16 -0
 - data/ext/hitimes_instant_windows.c +27 -0
 - data/ext/hitimes_interval.c +340 -0
 - data/ext/hitimes_interval.h +73 -0
 - data/ext/hitimes_stats.c +241 -0
 - data/ext/hitimes_stats.h +30 -0
 - data/ext/rbconfig-mingw.rb +178 -0
 - data/ext/rbconfig.rb +178 -0
 - data/gemspec.rb +55 -0
 - data/lib/hitimes.rb +21 -0
 - data/lib/hitimes/paths.rb +54 -0
 - data/lib/hitimes/timer.rb +223 -0
 - data/lib/hitimes/version.rb +42 -0
 - data/lib/hitimes_ext.so +0 -0
 - data/spec/interval_spec.rb +115 -0
 - data/spec/paths_spec.rb +14 -0
 - data/spec/spec_helper.rb +6 -0
 - data/spec/stats_spec.rb +48 -0
 - data/spec/timer_spec.rb +105 -0
 - data/spec/version_spec.rb +27 -0
 - data/tasks/announce.rake +39 -0
 - data/tasks/config.rb +107 -0
 - data/tasks/distribution.rake +53 -0
 - data/tasks/documentation.rake +33 -0
 - data/tasks/extension.rake +64 -0
 - data/tasks/rspec.rake +31 -0
 - data/tasks/rubyforge.rake +52 -0
 - data/tasks/utils.rb +80 -0
 - metadata +134 -0
 
| 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'tasks/config'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            #-------------------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Distribution and Packaging
         
     | 
| 
      
 5 
     | 
    
         
            +
            #-------------------------------------------------------------------------------
         
     | 
| 
      
 6 
     | 
    
         
            +
            if pkg_config = Configuration.for_if_exist?("packaging") then
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              require 'gemspec'
         
     | 
| 
      
 9 
     | 
    
         
            +
              require 'rake/gempackagetask'
         
     | 
| 
      
 10 
     | 
    
         
            +
              require 'rake/contrib/sshpublisher'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              namespace :dist do
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                Rake::GemPackageTask.new(Hitimes::GEM_SPEC) do |pkg|
         
     | 
| 
      
 15 
     | 
    
         
            +
                  pkg.need_tar = pkg_config.formats.tgz
         
     | 
| 
      
 16 
     | 
    
         
            +
                  pkg.need_zip = pkg_config.formats.zip
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                desc "Install as a gem"
         
     | 
| 
      
 20 
     | 
    
         
            +
                task :install => [:clobber, :package] do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  sh "sudo gem install pkg/#{Hitimes::GEM_SPEC.full_name}.gem"
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                desc "Uninstall gem"
         
     | 
| 
      
 25 
     | 
    
         
            +
                task :uninstall do 
         
     | 
| 
      
 26 
     | 
    
         
            +
                  sh "sudo gem uninstall -x #{Hitimes::GEM_SPEC.name}"
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                desc "dump gemspec"
         
     | 
| 
      
 30 
     | 
    
         
            +
                task :gemspec do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  puts Hitimes::GEM_SPEC.to_ruby
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                desc "reinstall gem"
         
     | 
| 
      
 35 
     | 
    
         
            +
                task :reinstall => [:uninstall, :repackage, :install]
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                desc "package up a windows gem"
         
     | 
| 
      
 38 
     | 
    
         
            +
                task :package_win => "ext:build_win" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  cp "ext/hitimes_ext.so", "lib", :verbose => true
         
     | 
| 
      
 40 
     | 
    
         
            +
                  Gem::Builder.new( Hitimes::GEM_SPEC_WIN ).build 
         
     | 
| 
      
 41 
     | 
    
         
            +
                  mv Dir["*.gem"].first, "pkg"
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                desc "distribute copiously"
         
     | 
| 
      
 45 
     | 
    
         
            +
                task :copious => [:package, :package_win ] do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  gems = Hitimes::SPECS.collect { |s| "#{s.full_name}.gem" }
         
     | 
| 
      
 47 
     | 
    
         
            +
                  Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
         
     | 
| 
      
 48 
     | 
    
         
            +
                                           '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
         
     | 
| 
      
 49 
     | 
    
         
            +
                                           'pkg', *gems).upload
         
     | 
| 
      
 50 
     | 
    
         
            +
                  sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
         
     | 
| 
      
 51 
     | 
    
         
            +
                end 
         
     | 
| 
      
 52 
     | 
    
         
            +
             end
         
     | 
| 
      
 53 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'tasks/config'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            #-----------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Documentation
         
     | 
| 
      
 5 
     | 
    
         
            +
            #-----------------------------------------------------------------------
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            if rdoc_config = Configuration.for_if_exist?('rdoc') then
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              namespace :doc do
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                require 'rake/rdoctask'
         
     | 
| 
      
 12 
     | 
    
         
            +
                #gem 'darkfish-rdoc'
         
     | 
| 
      
 13 
     | 
    
         
            +
                #require 'darkfish-rdoc'
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                # generating documentation locally
         
     | 
| 
      
 16 
     | 
    
         
            +
                Rake::RDocTask.new do |rdoc|
         
     | 
| 
      
 17 
     | 
    
         
            +
                  rdoc.rdoc_dir   = rdoc_config.output_dir
         
     | 
| 
      
 18 
     | 
    
         
            +
                  rdoc.options    = rdoc_config.options
         
     | 
| 
      
 19 
     | 
    
         
            +
                  rdoc.rdoc_files = rdoc_config.files.sort
         
     | 
| 
      
 20 
     | 
    
         
            +
                  rdoc.title      = rdoc_config.title
         
     | 
| 
      
 21 
     | 
    
         
            +
                  rdoc.main       = rdoc_config.main_page
         
     | 
| 
      
 22 
     | 
    
         
            +
                end 
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
         
     | 
| 
      
 25 
     | 
    
         
            +
                  desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
         
     | 
| 
      
 26 
     | 
    
         
            +
                  task :deploy => :rerdoc do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end 
         
     | 
| 
      
 29 
     | 
    
         
            +
                end 
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              end 
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'tasks/config'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'pathname'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #-----------------------------------------------------------------------
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Extensions
         
     | 
| 
      
 6 
     | 
    
         
            +
            #-----------------------------------------------------------------------
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            if ext_config = Configuration.for_if_exist?('extension') then
         
     | 
| 
      
 9 
     | 
    
         
            +
              namespace :ext do  
         
     | 
| 
      
 10 
     | 
    
         
            +
                desc "Build the extension(s)"
         
     | 
| 
      
 11 
     | 
    
         
            +
                task :build do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Hitimes::GEM_SPEC.extensions.each do |extension|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    path = Pathname.new(extension)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    parts = path.split
         
     | 
| 
      
 15 
     | 
    
         
            +
                    conf = parts.last
         
     | 
| 
      
 16 
     | 
    
         
            +
                    Dir.chdir(path.dirname) do |d| 
         
     | 
| 
      
 17 
     | 
    
         
            +
                      ruby conf.to_s
         
     | 
| 
      
 18 
     | 
    
         
            +
                      #sh "rake default"
         
     | 
| 
      
 19 
     | 
    
         
            +
                      sh "make" 
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                end 
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                desc "Build the extension for windows"
         
     | 
| 
      
 25 
     | 
    
         
            +
                task :build_win => :clobber do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  Hitimes::GEM_SPEC.extensions.each do |extension|
         
     | 
| 
      
 27 
     | 
    
         
            +
                    path = Pathname.new(extension)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    parts = path.split
         
     | 
| 
      
 29 
     | 
    
         
            +
                    conf = parts.last
         
     | 
| 
      
 30 
     | 
    
         
            +
                    Dir.chdir(path.dirname) do |d| 
         
     | 
| 
      
 31 
     | 
    
         
            +
                      cp "rbconfig-mingw.rb", "rbconfig.rb"
         
     | 
| 
      
 32 
     | 
    
         
            +
                      sh "ruby -I. extconf.rb"
         
     | 
| 
      
 33 
     | 
    
         
            +
                      sh "make"
         
     | 
| 
      
 34 
     | 
    
         
            +
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                task :clean do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  ext_config.configs.each do |extension|
         
     | 
| 
      
 40 
     | 
    
         
            +
                    path  = Pathname.new(extension)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    parts = path.split
         
     | 
| 
      
 42 
     | 
    
         
            +
                    conf  = parts.last
         
     | 
| 
      
 43 
     | 
    
         
            +
                    Dir.chdir(path.dirname) do |d| 
         
     | 
| 
      
 44 
     | 
    
         
            +
                      #sh "rake clean"
         
     | 
| 
      
 45 
     | 
    
         
            +
                      sh "make clean"
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end 
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end 
         
     | 
| 
      
 48 
     | 
    
         
            +
                end 
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                task :clobber do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  ext_config.configs.each do |extension|
         
     | 
| 
      
 52 
     | 
    
         
            +
                    path  = Pathname.new(extension)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    parts = path.split
         
     | 
| 
      
 54 
     | 
    
         
            +
                    conf  = parts.last
         
     | 
| 
      
 55 
     | 
    
         
            +
                    Dir.chdir(path.dirname) do |d| 
         
     | 
| 
      
 56 
     | 
    
         
            +
                      #sh "rake clobber"
         
     | 
| 
      
 57 
     | 
    
         
            +
                      if File.exist?( "Makefile" ) then
         
     | 
| 
      
 58 
     | 
    
         
            +
                        sh "make distclean"
         
     | 
| 
      
 59 
     | 
    
         
            +
                      end
         
     | 
| 
      
 60 
     | 
    
         
            +
                    end 
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end 
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
    
        data/tasks/rspec.rake
    ADDED
    
    | 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require 'tasks/config'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #--------------------------------------------------------------------------------
         
     | 
| 
      
 5 
     | 
    
         
            +
            # configuration for running rspec.  This shows up as the test:default task
         
     | 
| 
      
 6 
     | 
    
         
            +
            #--------------------------------------------------------------------------------
         
     | 
| 
      
 7 
     | 
    
         
            +
            if spec_config = Configuration.for_if_exist?("test") then
         
     | 
| 
      
 8 
     | 
    
         
            +
              if spec_config.mode == "spec" then
         
     | 
| 
      
 9 
     | 
    
         
            +
                namespace :test do
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  task :default => :spec
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  require 'spec/rake/spectask'
         
     | 
| 
      
 14 
     | 
    
         
            +
                  Spec::Rake::SpecTask.new do |r| 
         
     | 
| 
      
 15 
     | 
    
         
            +
                    r.ruby_opts   = spec_config.ruby_opts
         
     | 
| 
      
 16 
     | 
    
         
            +
                    r.libs        = [ Hitimes::Paths.lib_path, 
         
     | 
| 
      
 17 
     | 
    
         
            +
                                      Hitimes::Paths.root_dir ]
         
     | 
| 
      
 18 
     | 
    
         
            +
                    r.spec_files  = spec_config.files 
         
     | 
| 
      
 19 
     | 
    
         
            +
                    r.spec_opts   = spec_config.options
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    if rcov_config = Configuration.for_if_exist?('rcov') then
         
     | 
| 
      
 22 
     | 
    
         
            +
                      r.rcov      = true
         
     | 
| 
      
 23 
     | 
    
         
            +
                      r.rcov_dir  = rcov_config.output_dir
         
     | 
| 
      
 24 
     | 
    
         
            +
                      r.rcov_opts = rcov_config.rcov_opts
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  task :spec => "ext:build"
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'tasks/config'    
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            #-----------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Rubyforge additions to the task library
         
     | 
| 
      
 5 
     | 
    
         
            +
            #-----------------------------------------------------------------------
         
     | 
| 
      
 6 
     | 
    
         
            +
            if rf_conf = Configuration.for_if_exist?("rubyforge") then
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              abort("rubyforge gem not installed 'gem install rubyforge'") unless Utils.try_require('rubyforge')
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              proj_conf = Configuration.for('project')
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              namespace :dist do
         
     | 
| 
      
 13 
     | 
    
         
            +
                desc "Release files to rubyforge"
         
     | 
| 
      
 14 
     | 
    
         
            +
                task :rubyforge => [:clean, :package, :package_win] do
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  rubyforge = RubyForge.new
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  config = {}
         
     | 
| 
      
 19 
     | 
    
         
            +
                  config["release_notes"]     = proj_conf.description
         
     | 
| 
      
 20 
     | 
    
         
            +
                  config["release_changes"]   = Utils.release_notes_from(proj_conf.history)[Hitimes::VERSION]
         
     | 
| 
      
 21 
     | 
    
         
            +
                  config["Prefomatted"]       = true
         
     | 
| 
      
 22 
     | 
    
         
            +
             
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  rubyforge.configure config
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  # make sure this release doesn't already exist
         
     | 
| 
      
 27 
     | 
    
         
            +
                  releases = rubyforge.autoconfig['release_ids']
         
     | 
| 
      
 28 
     | 
    
         
            +
                  if releases.has_key?(Hitimes::GEM_SPEC.name) and releases[Hitimes::GEM_SPEC.name][Hitimes::VERSION] then
         
     | 
| 
      
 29 
     | 
    
         
            +
                    abort("Release #{Hitimes::VERSION} already exists! Unable to release.")
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  puts "Uploading to rubyforge..."
         
     | 
| 
      
 33 
     | 
    
         
            +
                  files = FileList[File.join("pkg","#{Hitimes::GEM_SPEC.name}-#{Hitimes::VERSION}*.*")].to_a
         
     | 
| 
      
 34 
     | 
    
         
            +
                  rubyforge.login
         
     | 
| 
      
 35 
     | 
    
         
            +
                  rubyforge.add_release(Hitimes::GEM_SPEC.rubyforge_project, Hitimes::GEM_SPEC.name, Hitimes::VERSION, *files)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  puts "done."
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              namespace :announce do
         
     | 
| 
      
 41 
     | 
    
         
            +
                desc "Post news of #{proj_conf.name} to #{rf_conf.project} on rubyforge"
         
     | 
| 
      
 42 
     | 
    
         
            +
                task :rubyforge do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  info = Utils.announcement
         
     | 
| 
      
 44 
     | 
    
         
            +
                  rubyforge = RubyForge.new
         
     | 
| 
      
 45 
     | 
    
         
            +
                  rubyforge.configure
         
     | 
| 
      
 46 
     | 
    
         
            +
                  rubyforge.login
         
     | 
| 
      
 47 
     | 
    
         
            +
                  rubyforge.post_news(rf_conf.project, info[:subject], "#{info[:title]}\n\n#{info[:urls]}\n\n#{info[:release_notes]}")
         
     | 
| 
      
 48 
     | 
    
         
            +
                  puts "Posted to rubyforge"
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
    
        data/tasks/utils.rb
    ADDED
    
    | 
         @@ -0,0 +1,80 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'hitimes/version'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            #-------------------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Additions to the Configuration class that are useful
         
     | 
| 
      
 5 
     | 
    
         
            +
            #-------------------------------------------------------------------------------
         
     | 
| 
      
 6 
     | 
    
         
            +
            class Configuration
         
     | 
| 
      
 7 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 8 
     | 
    
         
            +
                def exist?( name )
         
     | 
| 
      
 9 
     | 
    
         
            +
                  Configuration::Table.has_key?( name )
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def for_if_exist?( name )
         
     | 
| 
      
 13 
     | 
    
         
            +
                  if self.exist?( name ) then
         
     | 
| 
      
 14 
     | 
    
         
            +
                    self.for( name )
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            #-------------------------------------------------------------------------------
         
     | 
| 
      
 21 
     | 
    
         
            +
            # some useful utilitiy methods for the tasks
         
     | 
| 
      
 22 
     | 
    
         
            +
            #-------------------------------------------------------------------------------
         
     | 
| 
      
 23 
     | 
    
         
            +
            module Utils
         
     | 
| 
      
 24 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # Try to load the given _library_ using the built-in require, but do not
         
     | 
| 
      
 27 
     | 
    
         
            +
                # raise a LoadError if unsuccessful. Returns +true+ if the _library_ was
         
     | 
| 
      
 28 
     | 
    
         
            +
                # successfully loaded; returns +false+ otherwise.
         
     | 
| 
      
 29 
     | 
    
         
            +
                #
         
     | 
| 
      
 30 
     | 
    
         
            +
                def try_require( lib ) 
         
     | 
| 
      
 31 
     | 
    
         
            +
                  require lib
         
     | 
| 
      
 32 
     | 
    
         
            +
                  true 
         
     | 
| 
      
 33 
     | 
    
         
            +
                rescue LoadError 
         
     | 
| 
      
 34 
     | 
    
         
            +
                  false 
         
     | 
| 
      
 35 
     | 
    
         
            +
                end 
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                # partition an rdoc file into sections, and return the text of the section
         
     | 
| 
      
 38 
     | 
    
         
            +
                # given.  
         
     | 
| 
      
 39 
     | 
    
         
            +
                def section_of(file, section_name) 
         
     | 
| 
      
 40 
     | 
    
         
            +
                  File.read(file).split(/^(?==)/).each do |section|
         
     | 
| 
      
 41 
     | 
    
         
            +
                    lines = section.split("\n")
         
     | 
| 
      
 42 
     | 
    
         
            +
                    return lines[1..-1].join("\n").strip if lines.first =~ /#{section_name}/i
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                # Get an array of all the changes in the application for a particular
         
     | 
| 
      
 48 
     | 
    
         
            +
                # release.  This is done by looking in the history file and grabbing the
         
     | 
| 
      
 49 
     | 
    
         
            +
                # information for the most recent release.  The history file is assumed to
         
     | 
| 
      
 50 
     | 
    
         
            +
                # be in RDoc format and version release are 2nd tier sections separated by
         
     | 
| 
      
 51 
     | 
    
         
            +
                # '== Version X.Y.Z'
         
     | 
| 
      
 52 
     | 
    
         
            +
                #
         
     | 
| 
      
 53 
     | 
    
         
            +
                # returns:: A hash of notes keyed by version number
         
     | 
| 
      
 54 
     | 
    
         
            +
                #
         
     | 
| 
      
 55 
     | 
    
         
            +
                def release_notes_from(history_file)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  releases = {}
         
     | 
| 
      
 57 
     | 
    
         
            +
                  File.read(history_file).split(/^(?=== Version)/).each do |section|
         
     | 
| 
      
 58 
     | 
    
         
            +
                    lines = section.split("\n")
         
     | 
| 
      
 59 
     | 
    
         
            +
                    md = %r{Version ((\w+\.)+\w+)}.match(lines.first)
         
     | 
| 
      
 60 
     | 
    
         
            +
                    next unless md
         
     | 
| 
      
 61 
     | 
    
         
            +
                    releases[md[1]] = lines[1..-1].join("\n").strip
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
                  return releases
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                # return a hash of useful information for the latest release
         
     | 
| 
      
 67 
     | 
    
         
            +
                # urls, subject, title, description and latest release notes
         
     | 
| 
      
 68 
     | 
    
         
            +
                #
         
     | 
| 
      
 69 
     | 
    
         
            +
                def announcement
         
     | 
| 
      
 70 
     | 
    
         
            +
                  cfg = Configuration.for("project") 
         
     | 
| 
      
 71 
     | 
    
         
            +
                  { 
         
     | 
| 
      
 72 
     | 
    
         
            +
                    :subject        => "#{cfg.name} #{Hitimes::VERSION} Released",
         
     | 
| 
      
 73 
     | 
    
         
            +
                    :title          => "#{cfg.name} version #{Hitimes::VERSION} has been released.",
         
     | 
| 
      
 74 
     | 
    
         
            +
                    :urls           => "#{cfg.homepage}",
         
     | 
| 
      
 75 
     | 
    
         
            +
                    :description    => "#{cfg.description.rstrip}",
         
     | 
| 
      
 76 
     | 
    
         
            +
                    :release_notes  => Utils.release_notes_from(cfg.history)[Hitimes::VERSION].rstrip 
         
     | 
| 
      
 77 
     | 
    
         
            +
                  }
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
            end # << self
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,134 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: hitimes
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: x86-mswin32-60
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Jeremy Hinegardner
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-10-11 00:00:00 -06:00
         
     | 
| 
      
 13 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 17 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 18 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 19 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 20 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 22 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 23 
     | 
    
         
            +
                    version: 0.8.1
         
     | 
| 
      
 24 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: configuration
         
     | 
| 
      
 27 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 28 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 29 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 0.0.5
         
     | 
| 
      
 34 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 35 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 36 
     | 
    
         
            +
              name: mkrf
         
     | 
| 
      
 37 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 38 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 39 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: 0.2.3
         
     | 
| 
      
 44 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            description: Hitimes is a fast, high resolution timer library for recording performance metrics.  It uses the appropriate C method calls for each system to get the highest granularity time increments possible.    It currently supports any system with the POSIX call clock_gettime() and OSX. Windows is in the works.  Using Hitimes can be faster than using a series of Time.new calls, and it will have a much higher granularity.   It is definitely faster than using Process.times.
         
     | 
| 
      
 46 
     | 
    
         
            +
            email: jeremy@copiousfreetime.org
         
     | 
| 
      
 47 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 52 
     | 
    
         
            +
            - README
         
     | 
| 
      
 53 
     | 
    
         
            +
            - HISTORY
         
     | 
| 
      
 54 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/hitimes/paths.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib/hitimes/timer.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/hitimes/version.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/hitimes.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - ext/hitimes_ext.c
         
     | 
| 
      
 60 
     | 
    
         
            +
            - ext/hitimes_instant_clock_gettime.c
         
     | 
| 
      
 61 
     | 
    
         
            +
            - ext/hitimes_instant_osx.c
         
     | 
| 
      
 62 
     | 
    
         
            +
            - ext/hitimes_instant_windows.c
         
     | 
| 
      
 63 
     | 
    
         
            +
            - ext/hitimes_interval.c
         
     | 
| 
      
 64 
     | 
    
         
            +
            - ext/hitimes_stats.c
         
     | 
| 
      
 65 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 66 
     | 
    
         
            +
            - examples/benchmarks.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - examples/stats.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - ext/hitimes_ext.c
         
     | 
| 
      
 69 
     | 
    
         
            +
            - ext/hitimes_instant_clock_gettime.c
         
     | 
| 
      
 70 
     | 
    
         
            +
            - ext/hitimes_instant_osx.c
         
     | 
| 
      
 71 
     | 
    
         
            +
            - ext/hitimes_instant_windows.c
         
     | 
| 
      
 72 
     | 
    
         
            +
            - ext/hitimes_interval.c
         
     | 
| 
      
 73 
     | 
    
         
            +
            - ext/hitimes_stats.c
         
     | 
| 
      
 74 
     | 
    
         
            +
            - ext/hitimes_interval.h
         
     | 
| 
      
 75 
     | 
    
         
            +
            - ext/hitimes_stats.h
         
     | 
| 
      
 76 
     | 
    
         
            +
            - ext/extconf.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - ext/rbconfig-mingw.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - ext/rbconfig.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
            - lib/hitimes/paths.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - lib/hitimes/timer.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - lib/hitimes/version.rb
         
     | 
| 
      
 82 
     | 
    
         
            +
            - lib/hitimes.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
            - spec/interval_spec.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - spec/paths_spec.rb
         
     | 
| 
      
 85 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 86 
     | 
    
         
            +
            - spec/stats_spec.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            - spec/timer_spec.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            - spec/version_spec.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - README
         
     | 
| 
      
 90 
     | 
    
         
            +
            - HISTORY
         
     | 
| 
      
 91 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 92 
     | 
    
         
            +
            - tasks/announce.rake
         
     | 
| 
      
 93 
     | 
    
         
            +
            - tasks/distribution.rake
         
     | 
| 
      
 94 
     | 
    
         
            +
            - tasks/documentation.rake
         
     | 
| 
      
 95 
     | 
    
         
            +
            - tasks/extension.rake
         
     | 
| 
      
 96 
     | 
    
         
            +
            - tasks/rspec.rake
         
     | 
| 
      
 97 
     | 
    
         
            +
            - tasks/rubyforge.rake
         
     | 
| 
      
 98 
     | 
    
         
            +
            - tasks/config.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - tasks/utils.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 101 
     | 
    
         
            +
            - gemspec.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - lib/hitimes_ext.so
         
     | 
| 
      
 103 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 104 
     | 
    
         
            +
            homepage: http://copiousfreetime.rubyforge.org/hitimes/
         
     | 
| 
      
 105 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 106 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 107 
     | 
    
         
            +
            - --line-numbers
         
     | 
| 
      
 108 
     | 
    
         
            +
            - --inline-source
         
     | 
| 
      
 109 
     | 
    
         
            +
            - --main
         
     | 
| 
      
 110 
     | 
    
         
            +
            - README
         
     | 
| 
      
 111 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 112 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 113 
     | 
    
         
            +
            - ext
         
     | 
| 
      
 114 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 115 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 116 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 117 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 118 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 119 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 120 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 121 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 122 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 123 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 124 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 125 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 126 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            rubyforge_project: copiousfreetime
         
     | 
| 
      
 129 
     | 
    
         
            +
            rubygems_version: 1.2.0
         
     | 
| 
      
 130 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 131 
     | 
    
         
            +
            specification_version: 2
         
     | 
| 
      
 132 
     | 
    
         
            +
            summary: Hitimes is a fast, high resolution timer library for recording performance metrics
         
     | 
| 
      
 133 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     |