Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:54:36+00:00 2026-06-07T16:54:36+00:00

I’m developing my first gem called t_time_tracker (woohoo!). All was going great in development;

  • 0

I’m developing my first gem called t_time_tracker (woohoo!). All was going great in development; I optomized it as much as I possibly could to cut execution time down to as little as possible:

t_time_tracker[master*]% time ruby -Ilib ./bin/t_time_tracker 
You're not working on anything
0.07s user 0.03s system 67% cpu 0.141 total

(this is the “hello world” of my app – calling it with no parameters just prints out “You’re not working on anything”)

About a tenth of a second and uses 67% of my CPU – cool, I can live with that. It feels fairly instantaneous. Let’s build it:

$ gem build t_time_tracker.gemspec
$ gem install ./t_time_tracker-0.0.0.gem

And do the exact same thing with the installed binary:

$ time t_time_tracker
You're not working on anything
t_time_tracker  0.42s user 0.06s system 93% cpu 0.513 total

Half a second?! Where did that come from?! Let’s add some debugging output and include the system gem from the development binary to see where the bottleneck is:

t_time_tracker[master*]% time ruby ./bin/t_time_tracker  
(starting binary)
(require 'time' and 'optparse')
0.041432
(before `require 't_time_tracker')
0.497135
(after `require 't_time_tracker')
(Gem.loaded_specs.keys = t_time_tracker)
(initializing TTimeTracker class)
You're not working on anything
ruby ./bin/t_time_tracker  0.44s user 0.07s system 91% cpu 0.551 total

Alright, so the `require ‘t_time_tracker’ line seems to be the culprit. Let’s try again in irb to narrow it down further:

$ irb
>> t=Time.now; require 't_time_tracker'; puts Time.now-t
0.046792
=> nil

…what? But that was just taking half a second! Let’s try building the gem with our debugging output:

$ gem build t_time_tracker.gemspec
$ gem install ./t_time_tracker-0.0.0.gem
$ time t_time_tracker
(starting binary) <---noticeable half second delay before this line shows up
(require 'time' and 'optparse')
0.050458
(before `require 't_time_tracker')
0.073789
(after `require 't_time_tracker')
(Gem.loaded_specs.keys = t_time_tracker)
(initializing TTimeTracker class)
You're not working on anything
t_time_tracker  0.42s user 0.06s system 88% cpu 0.546 total

So yeah, where is this 0.5 second delay coming from? I usually wouldn’t care, but this is something that I’m calling about fifty times a day to update what I’m doing. 50 * 0.5 seconds * 365 days * 70 years = 15 days of lost life.

System information:

Mac OS X 10.7.3. 2 GHz Intel Core 2 Duo. 4 GB ram. ruby 1.9.2p290.

% gem -v
1.8.10<---noticeable half second delay before this line shows up
% gem list | wc -l
209
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:54:38+00:00Added an answer on June 7, 2026 at 4:54 pm

    Been a while since I looked at this but RubyGems has, in the past (and maybe the present), taken a long time to load for mainly two reasons:

    • It would load many relatively expensive libraries like ‘time’ via ‘yaml’. Usually you don’t care because it’s slow relative to ruby all by itself, not slow compared to the run time of many scripts.
    • It would scan over all the installed gems and load the most recent gemspecs into memory. This took a long time if you have a lot of gems.

    These issues may or may not still be in play. However you’ll always have some overhead from RubyGems. If you really need performance, then just set up your load path yourself! Ruby without RubyGems is very fast, as you know.

    To see where your gem is installed:

    gem list -d YOUR_GEM_NAME
    

    You’ll see the install directory. Your gem will be at INSTALL_DIR/gems/GEM_NAME-VERSION so try executing:

    time ruby -IINSTALL_DIR/gems/GEM_NAME-VERSION/lib INSTALL_DIR/gems/GEM_NAME-VERSION/bin/t_time_tracker
    

    That’s a lot, but you should be able to wrap this in a separate script, something like this (name it t_time_tracker):

    #!/usr/bin/env ruby -IINSTALL_DIR/gems/GEM_NAME-VERSION/lib
    load 'INSTALL_DIR/gems/GEM_NAME-VERSION/bin/t_time_tracker'
    

    Then:

    chmod +x t_time_tracker
    time ./t_time_tracker
    

    And put that file anywhere along your PATH. RubyGems does for you automatically, but of course you then accept the overhead of RubyGems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.