Sha256: ae47ead0f65e2c3cbe14f07e9361adf12c32a580e32b65db3b33e04d21afe263
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
# Copyright (C) 2012-2024 Sutou Kouhei <kou@clear-code.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. module Grntest class BaseResult attr_accessor :cpu_elapsed_time attr_accessor :real_elapsed_time def initialize @cpu_elapsed_time = 0 @real_elapsed_time = 0 end def measure cpu_start_time = Process.times real_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield ensure cpu_finish_time = Process.times real_finish_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) @cpu_elapsed_time = (cpu_finish_time.utime - cpu_start_time.utime) + (cpu_finish_time.stime - cpu_start_time.stime) + (cpu_finish_time.cutime - cpu_start_time.cutime) + (cpu_finish_time.cstime - cpu_start_time.cstime) @real_elapsed_time = real_finish_time - real_start_time end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
grntest-1.7.0 | lib/grntest/base-result.rb |
grntest-1.6.9 | lib/grntest/base-result.rb |
grntest-1.6.8 | lib/grntest/base-result.rb |
grntest-1.6.7 | lib/grntest/base-result.rb |