diff options
author | Eileen Uchitelle <eileencodes@gmail.com> | 2018-07-26 12:55:59 -0400 |
---|---|---|
committer | Eileen Uchitelle <eileencodes@gmail.com> | 2018-07-26 13:57:51 -0400 |
commit | 42fec4b8de8c40d7778f936e200081c0dded1ed0 (patch) | |
tree | b8d270fd84dab28436b934cb35285b024165ee2d /activesupport/test | |
parent | 15a72c6c05cfc5250ee04742b4f45463f937d3f7 (diff) | |
download | rails-42fec4b8de8c40d7778f936e200081c0dded1ed0.tar.gz rails-42fec4b8de8c40d7778f936e200081c0dded1ed0.tar.bz2 rails-42fec4b8de8c40d7778f936e200081c0dded1ed0.zip |
Add cpu_time, idle_time, and allocations to Event
* Use process clock instead of Time.now
This fixes any issues with the system clock changing and also eliminates
2 object allocations per event.
* Add start! and finish! methods to the event object so we can record
more information
* Adds cpu time, idle time, and allocation count for a particular event.
Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/log_subscriber_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/test/log_subscriber_test.rb b/activesupport/test/log_subscriber_test.rb index 2af9b1de30..4f413b9627 100644 --- a/activesupport/test/log_subscriber_test.rb +++ b/activesupport/test/log_subscriber_test.rb @@ -75,6 +75,17 @@ class SyncLogSubscriberTest < ActiveSupport::TestCase assert_kind_of ActiveSupport::Notifications::Event, @log_subscriber.event end + def test_event_attributes + ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber + instrument "some_event.my_log_subscriber" + wait + event = @log_subscriber.event + assert_operator event.duration, :>, 0 + assert_operator event.cpu_time, :>, 0 + assert_operator event.idle_time, :>, 0 + assert_operator event.allocations, :>, 0 + end + def test_does_not_send_the_event_if_it_doesnt_match_the_class ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber instrument "unknown_event.my_log_subscriber" |