#368 MiniProfiler
MiniProfiler allows you to see the speed of a request conveniently on the page. It also shows the SQL queries performed and allows you to profile a specific block of code.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
Big thanks Ryan, for the excellent Railscast!
Unfortunately, I couldn't ran this on my Project:
gems/rack-mini-profiler-0.1.7/lib/mini_profiler/storage/memory_store.rb:17:in
block in initialize': private method
cleanup_cache' called for #Rack::MiniProfiler::MemoryStore:0x00000003bcb670 (NoMethodError)The line of this error:
https://github.com/SamSaffron/MiniProfiler/blob/master/Ruby/lib/mini_profiler/storage/memory_store.rb#L17
I tried with FileStorage too:
gems/rack-mini-profiler-0.1.7/lib/mini_profiler/storage/file_store.rb:43:in
block in initialize': undefined method
instance' for Rack::MiniProfiler:Class (NoMethodError)My project is running Rails 3.2.7 with ruby 1.9.3-p194
This is a great little gem to see what overheads you are getting in your app due to not slim lining your SQL statements +1
Thanks Ryan, for Great Tutorial.
I tried with your example_before application. But, it doesn't show the small Profiler box on left side.
I just added this gem 'rack-mini-profiler' on my Gemfile (example_before).
Is it enough?. Or need to make any additional configuration.
what version of rails/ruby are you running?
I'm using Ryan example tutorial file (example_before) which is provided by him. Version: rails 3.2.6 and Ruby 1.9.3.
Hi,ryan i couldn't create a SCAFFOLD...?
It throws error
`require': no such file to load --
json (LoadError)
Only when i include gem 'rack-mini-profiler' or else it's fine...
Help me to come out...
what version of rails/ruby are you running?
Hmm.. I installed the gem and the profiler tab shows up and displays the amount of time that loading took for a page, but it reports 0 sql queries for all pages. Any idea what's going on? I'm using postgres, but that shouldn't matter.
Try updating the pg gem. That did the trick for me.
interesting, @clay what version of the pg gem are your running? We are forced to monkey patch the async version of pg exec, perhaps we should fall back to the non async ones as well
I updated from 0.11 to 0.14 BTW
Same here 0.11 to 0.14 fixed this...
me too, I'm using postgres
$ gem list pg
*** LOCAL GEMS ***
pg (0.14.0)
How I do fix that?
do you happen to have the mysql gem as well in your gem file?
Just switched from MySQL to PostgreSQL and now seeing 0 SQL queries. I'm on
0.14.0
of the pg gem and do not have mysql in my Gemfile. Project is open source.UPDATE: Problem was that pg was being loaded after miniprofiler. I fixed this by moving the pg gem to the top level of my Gemfile (i.e. outside any groups).
Thanks, this did the trick!
Thanks for tutorial, just installed gem and nothing happened. FireBug console shows that every request POST http://0.0.0.0:3000/mini-profiler-resources/results is failed without any additional information =/
can you post a screen shot at http://community.miniprofiler.com ideally with the type of failure (is it a 404 or 500, what is in the error?)
Sorry, my mistake. Actually request is aborted.
https://dl.dropbox.com/u/4109351/tmp/rack-mini-profiler-firebug-1.png
Should I post issue to community tracker?
Also thanks for awesome gem :D
Btw I'm using rails 3.2.1 and ruby 1.9.3
yes, please do, with any relevant logs!
Here you are http://community.miniprofiler.com/permalinks/77/aborted-request-to-mini-profiler-resources-results
Very nice Ryan! Thanks!
@Sam, as a suggestion, a post about the .net->ruby conversion would be awesome. And thanks for the great job!
I think the core of it was in maintaining the client side code, the server side was re-written pretty much with some similar paradigms
My unicorn workers die if I add rack-mini-profiler to my Gemfile. Ryan, do you know why this is happening?
At the moment I am profiling with thin, because I did not get it to run with Unicorn, but for better estimating performance problems, I would really like to profile with my production web server (unicorn)
Would be glad about any hints.
Anyway, great episode!
Interesting, what version of rails/ruby are you running, is there anything in the logs about the failure? Do you mind posting on http://community.miniprofiler.com
Thanks for the introduction to MiniProfiler. I'm trying to use this on a 3.0.14 rails / 1.9.3-p194 ruby app without success.
Could not find any documentation about minimal requirements. Anyone having the same issue?
I have this working on 3.0.14 here, perhaps your version of rack is old, have you tried updating it?
I'm running rack 1.2.5 and having a hard time upgrading it, seems like rails 3.0.14 and 3.0.15 depend on exact this version or at least bundler insists on it..
Thanks for your support.
Yes, I have the same problem, Rails 3.0.15, Ruby 1.9.3-p125, Rack 1.2.5
I need to figure out a way to backport some of this to rack 1.2.5, at the moment it depends on a later rack
@dup2, have not tested 3.0.14, will test it out and reply on the community tracker.
Others, will try to respond to all the requests here today, but it would be mighty handy if you can post bugs/questions at http://community.miniprofiler.com
Hi @Sam - it works fine on my development machine but not on my production server, I get an 'Internal Server Error' and my production log shows:
Any ideas what's going on?
EDIT: I removed the http_basic_authenticate_with but it's still not working and there are no other clues in the log file :/
one thing that sticks out is that I did not do much 1.9.1 testing, also is there something about http authentication that you have configured in prd but not in dev?
@Sam
This is very promising. I am following Ryan's screencast and everything works fine on my dev machine, but I do not see the Profiler Tab in my production environment on my local machine. Is there something different in your local gem?
Thanks.
Bharat
it should work on both, are you whitelisting your requests?
Meaning declaring the model attributes with attr_accessible? If that is what you are asking, yes I am.
Try to clearing all browsing cache. It should work fine.
Many thanks. that did the trick. What an awesome tool!
Is there a plan to support mongoid?
+1
https://github.com/SamSaffron/MiniProfiler/tree/master/Ruby now supports mongoid 3
I installed miniprofiler as Ryan said. But, the miniprofiler don`t show itself in the index.
My Rails version is 3.0.15 and Ruby version is 1.9.2p180.
When running the rails with server mode, it gives me a
and the console log.
After that, i running the system from apache/passenger, but still, i couldn`t see the profiler in index, i see the index page source, it give me
Profiler, javascript code after the
</html>
tag..
So, i could not still see the profile.. bad.. so bad.
at the moment there is no support for rack 1.2.5, I am going to see what is involved in backporting
can you try the latest from github to see if it fixes it?
Hello Sam,
I use the latest github profiler.rb from miniprofiler, after that my error changed as follows
and the console is
How can i help you solving this problem? also thank you for your dealing..
yeah, that is not going to work, you are going to need to pull the whole tree
Can you try using latest, I think I sorted this out
All those who were having trouble, can you test again on 0.1.8, quite a few important fixes there
Looks like a great app!
I couldn't get it to work in my development environment, described in short the problem here:
http://community.miniprofiler.com/permalinks/85/rails-no-such-file-to-load----rack-mini-profiler-loaderror
Any hint?
Thanks for the wonderful gem!
Ruby 1.9.2p290, Rails 3.2.7, Windows 7 here.
Shows load times but the SQL column is empty.
The dev database is on sqlite.
Removing the pg gem from the gem file resolved the issue. The MySQL gem may also cause this to happen.
I've installed MiniProfiler with no problems, however I'm unable to find the configuration to allow more then 10 traces in the top left corder. The actual useful requests are getting "swallowed" by later smaller requests... (I can't precompile assets in order to reduce number of requests yet as I am on 3.0.x). Is such config option available?
I was trying the caching techniques from episode #321 and pulling my hair out trying to figure out why I wasn't get etag headers in my responses. Turns out that MiniProfiler strips the etag headers. It also rewrites the Cache-Control header.
From MiniProfiler source: mini-profiler/profiler.rb
Probably isn't a big deal because the profiler is disabled in production. But makes things trickier on the development side. Just wanted to share this in case anyone hits the same issue.
This makes me confusing for a long time. Thanks for your explanation.
Hi there,
first of all thanks to Ryan for a great RailsCast again and thanks to Sam for this wonderful gem.
No problem with installing the gem as expected. But I also do not see any SQL query times while profiling in development mode. Here's my setup:
ruby-1.9.3-p194 [ x86_64 ]
Using rails (3.2.8)
Using rack (1.4.1)
Using sqlite3 (1.3.6) for development
Using pg (0.14.1) for production (no MySQL gem)
Using newrelic_rpm (3.4.2)
Using thin (1.4.1)
Any progress in examining this issue? Do you want me to post this question / issue on http://community.miniprofiler.com ?
Thanks a lot
Andy
yes, please do. sqlite + pg means sqlite is not profiled
done ...
Cheers
Andy
Hi I am getting the following error when starting rails server after installing the gem using bundle install. Has anyone seen this and know how to resolve it. I am using ruby 1.8.7 and rails 3.2
ankur@ankurmac ~/D/c/b/openslot> rails s
/Users/ankur/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require': /Users/ankur/.rvm/gems/ruby-1.8.7-p370/gems/rack-mini-profiler-0.1.18/lib/mini_profiler/profiler.rb:375: syntax error, unexpected ')', expecting '=' (SyntaxError)
Found the error was in the profiler.rb script where there was a parameter after the optional parameter which was required when it should be optional as well with an = nil
After deploying in production it gave a 'Bad Gateway' error in browser. The corresponding error in the nginx error.log was "upstream prematurely closed connection while reading response header from upstream, client:" Any Ideas?
Very useful, thank you!
How can you tell how much loading time is too much?
For example, my home page takes ~340 ms to load in dev environment.
Is it too long or not?
I understand that it all depends on the complexity of my app, but I'm struggling with this because this's my first rails project and I simply doesn't know what performance time is OK.
Miniprofiler is showing many queries selecting from pg_attribute and pg_class. These queries are not in the development log. 14 of the 20 queries on one of my pages are these pg queries. Do these queries have to be run? If not how can I prevent them from running?
I reloaded my page and it seems these are not run again, so it must be some kind of 'first time the server loads' type queries.
In order for authorize_request and deauthorize_request to work, you have to set the authorize mode to whitelist.
application.rb
Rack::MiniProfiler.config.authorization_mode = :whitelist
Hi I am trying to add miniprofiler to mysite: https://wikigurus.com/.
First I tried in my local. I am getting below error
http://localhost:53506/mini-profiler-resources/includes.js?v=ySF6M98CBehTtL86BbiEmys9yxR1HKazhe2sznfdUWQ= 404 not found.
I also added the below code to web.config
Why it is throwing 404 error?
Awesome, keep going.
Do you think these are helpful?