Visualizzazione post con etichetta tutorial. Mostra tutti i post
Visualizzazione post con etichetta tutorial. Mostra tutti i post

sabato 12 aprile 2014

[Ruby] Memory profiling of a rake task with Ruby 1.9.3

These are only some notes to remember what I did to do a memory profiling of a rake task.

The environment was Ruby 1.9.3 with a Rails application and a Rake task to run in order to import the data in the DB.

The Rake task was just a wrapper for an Importer Object Class.

First add ruby-prof to the Gemfile:

gem "ruby-prof"

Then require it into the file you want to profile, and start to profile the task you want to track:

 require 'ruby-prof'
 
 def my_method()
   # We want to profile the Memory rather than Process time

   RubyProf.measure_mode = RubyProf::MEMORY
   # Start profile!
   RubyProf.start
  
   ... do your crazy stuff here...

   # Stop profiling and get the result
   result = RubyProf.end

   # Write the result in somewhere
   RubyProf.MultiPrinter.new(result).print { :path => "#{Rails.root}/", :profile => "profiling" }
 end

Easy, right?
Yeah, too much, in fact opening the profile.html the result will be a full stack of NaN... indeed have a look to this issue for 1.9.3 in ruby-prof.

So, what to do is to use RVM to install a patched version of 1.9.3 and try again!

$ rvm install 1.9.3-p194 --patch railsexpress

Go and make a tea while waiting for building...

At this point create a new gemset, bundle install and have another go with the profiling: this time it should work!

giovedì 24 gennaio 2013

[Skype] Screen sharing still free

Did you find last version of Skype (> 6.1.0 on OsX) doesn't let you share the screen while you're having a one-to-one chat?

Before what you had to do to share your screen during the video-call was to select 'Share Screen', right?

Now it asks you to buy Skype premium to restore the old feature you used a lot since they decided to take it off few days ago... but wait, the feature is not gone: it just became longer to activate.

So, during the next video-call, if you want to share your screen again, do the following:
  • Turn off your video
  • Activate 'Share Screen'
That's it.
Easy. Simple.
It can be done even by a script.

But some smart guy at Skype decided the user now has to do 2 more clicks for something like that.

So now say thanks to Skype for this nice move.