From 0712dfd6ae1423269af1512c3403ee1145f27de1 Mon Sep 17 00:00:00 2001 From: Gannon McGibbon Date: Thu, 8 Nov 2018 10:59:52 -0500 Subject: Windows support for parallelization and instrumenter Add Windows support for `ActiveSupport::Testing::Parallelization` and `ActiveSupport::Notifications::Instrumenter`. --- activesupport/lib/active_support/notifications/instrumenter.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/notifications/instrumenter.rb') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index f8344912bb..9184f8f54b 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -55,6 +55,11 @@ module ActiveSupport attr_reader :name, :time, :transaction_id, :payload, :children attr_accessor :end + def self.clock_gettime_supported? # :nodoc: + defined?(Process::CLOCK_PROCESS_CPUTIME_ID) && + !Gem.win_platform? + end + def initialize(name, start, ending, transaction_id, payload) @name = name @payload = payload.dup @@ -130,7 +135,7 @@ module ActiveSupport Process.clock_gettime(Process::CLOCK_MONOTONIC) end - if defined?(Process::CLOCK_PROCESS_CPUTIME_ID) + if clock_gettime_supported? def now_cpu Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID) end -- cgit v1.2.3 From 273292b8f1dca9108dddd032b7fc09c69c630fc1 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 20 Nov 2018 09:57:55 +0900 Subject: Deprecate `event.end = Time.now` in favor of `event.finish!` Since #33449, `event.end = Time.now` is not used anymore and should use `event.finish!`. We can't use `deprecate :end=` in definition time in this module due to circular require in `active_support/deprecation/behaviors`. --- activesupport/lib/active_support/notifications/instrumenter.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/notifications/instrumenter.rb') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 9184f8f54b..a721187d2d 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -52,8 +52,7 @@ module ActiveSupport end class Event - attr_reader :name, :time, :transaction_id, :payload, :children - attr_accessor :end + attr_reader :name, :time, :end, :transaction_id, :payload, :children def self.clock_gettime_supported? # :nodoc: defined?(Process::CLOCK_PROCESS_CPUTIME_ID) && @@ -88,6 +87,11 @@ module ActiveSupport @allocation_count_finish = now_allocations end + def end=(ending) + ActiveSupport::Deprecation.deprecation_warning(:end=, :finish!) + @end = ending + end + # Returns the CPU time (in milliseconds) passed since the call to # +start!+ and the call to +finish!+ def cpu_time -- cgit v1.2.3 From aa9b0932ecf2b35794de3836a1abb2cab39650de Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Fri, 30 Nov 2018 21:14:12 +0900 Subject: Don't expose internal `clock_gettime_supported?` class method --- activesupport/lib/active_support/notifications/instrumenter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/notifications/instrumenter.rb') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index a721187d2d..125c06f37a 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -56,8 +56,9 @@ module ActiveSupport def self.clock_gettime_supported? # :nodoc: defined?(Process::CLOCK_PROCESS_CPUTIME_ID) && - !Gem.win_platform? + !Gem.win_platform? end + private_class_method :clock_gettime_supported? def initialize(name, start, ending, transaction_id, payload) @name = name -- cgit v1.2.3