GithubHelp home page GithubHelp logo

igorkasyanchuk / execution_time Goto Github PK

View Code? Open in Web Editor NEW
115.0 4.0 3.0 4.76 MB

How fast is your code? See it directly in Rails console.

Home Page: https://www.railsjazz.com/

License: MIT License

Ruby 78.50% JavaScript 2.40% CSS 2.24% HTML 16.85%
rails performance rails-gem rails-application pry ruby ruby-on-rails

execution_time's Introduction

ExecutionTime

Listed on OpenSource-Heroes.com

Monitor execution time and other metrics directly in rails console, similar to what you see after each request.

[METRICS] Completed in 908.3ms | Allocations: 2894 | ActiveRecord: 0.9ms (queries: 13)

Usage

Just add this gem to the Gemfile and start rails c. After this try to do something like User.first.

If you want to measure few lines of code just wrap it with begin/end:

[4] pry(main)> begin
[4] pry(main)*   User.first.first_name.size
[4] pry(main)*   a = User.count + 1
[4] pry(main)*   b = User.second.last_name.size
[4] pry(main)* end  
  User Load (0.4ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1  [["LIMIT", 1]]
   (3.6ms)  SELECT COUNT(*) FROM "users"
  User Load (0.3ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 OFFSET $2  [["LIMIT", 1], ["OFFSET", 1]]
[METRICS]  Completed in 6.8ms | Allocations: 839 | ActiveRecord: 4.3ms (queries: 3)
=> 5

Installation

Add this line to your application's Gemfile:

gem 'execution_time'

First run

Sometime you can see that there are more SQL queries or allocated objects because Ruby is just loading objects in memory or verifying connection to the DB.

How to disable/enable metrics output in the console

If you need to disable gem in the console you can do it by ExecutionTime.disable!. And later enable with ExecutionTime.enable!.

By default gem is enabled.

Contributing

You are welcome to contribute.

Contributos

License

The gem is available as open source under the terms of the MIT License.

execution_time's People

Contributors

dependabot[bot] avatar igorkasyanchuk avatar nbulaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

execution_time's Issues

Deprecation Warning after Rails 7.1 upgrade.

After our project was upgraded to Rails 7.1 I've noticed deprecation warnings when using the rails console.

[1] pry(main)> test = 'foo'
DEPRECATION WARNING: ActiveRecord::LogSubscriber.reset_runtime is deprecated and will be removed in Rails 7.2. (called from <main> at bin/rails:4)
DEPRECATION WARNING: ActiveRecord::LogSubscriber.reset_runtime is deprecated and will be removed in Rails 7.2. (called from <main> at bin/rails:4)
[METRICS]  Completed in 0.5ms | Allocations: 207
=> "foo"

Unsure what method to swap to of if there even is one. But thought I'd at least make an issue for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.