Module: Process
- Defined in:
- opal/opal/corelib/process.rb,
opal/opal/corelib/process/status.rb more...
Defined Under Namespace
Classes: Status
Class Method Summary collapse
- .__register_clock__(name, func) ⇒ Object
- .clock_gettime(clock_id, unit = :float_second) ⇒ Object
- .pid ⇒ Object
- .times ⇒ Object
Class Method Details
.__register_clock__(name, func) ⇒ Object
[View source]
3 4 5 6 |
# File 'opal/opal/corelib/process.rb', line 3 def self.__register_clock__(name, func) const_set name, @__clocks__.size @__clocks__ << func end |
.clock_gettime(clock_id, unit = :float_second) ⇒ Object
[View source]
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'opal/opal/corelib/process.rb', line 41 def self.clock_gettime(clock_id, unit = :float_second) (clock = @__clocks__[clock_id]) || ::Kernel.raise(::Errno::EINVAL, "clock_gettime(#{clock_id}) #{@__clocks__[clock_id]}") %x{ var ms = clock(); switch (unit) { case 'float_second': return (ms / 1000); // number of seconds as a float (default) case 'float_millisecond': return (ms / 1); // number of milliseconds as a float case 'float_microsecond': return (ms * 1000); // number of microseconds as a float case 'second': return ((ms / 1000) | 0); // number of seconds as an integer case 'millisecond': return ((ms / 1) | 0); // number of milliseconds as an integer case 'microsecond': return ((ms * 1000) | 0); // number of microseconds as an integer case 'nanosecond': return ((ms * 1000000) | 0); // number of nanoseconds as an integer default: #{::Kernel.raise ::ArgumentError, "unexpected unit: #{unit}"} } } end |
.pid ⇒ Object
[View source]
32 33 34 |
# File 'opal/opal/corelib/process.rb', line 32 def self.pid 0 end |
.times ⇒ Object
[View source]
36 37 38 39 |
# File 'opal/opal/corelib/process.rb', line 36 def self.times t = ::Time.now.to_f ::Benchmark::Tms.new(t, t, t, t, t) end |