Add bin and edit workflow
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s

This commit is contained in:
2026-09-16 13:11:16 -06:00
parent c8ac4fcae5
commit 4cee170d66
17576 changed files with 895740 additions and 2 deletions
+74
View File
@@ -0,0 +1,74 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2018-2022, by Samuel Williams.
module Async
# A convenient wrapper around the internal monotonic clock.
# @public Since *Async v1*.
class Clock
# Get the current elapsed monotonic time.
def self.now
::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
end
# Measure the execution of a block of code.
# @yields {...} The block to execute.
# @returns [Numeric] The total execution time.
def self.measure
start_time = self.now
yield
return self.now - start_time
end
# Start measuring elapsed time from now.
# @returns [Clock]
def self.start
self.new.tap(&:start!)
end
# Create a new clock with the initial total time.
# @parameter total [Numeric] The initial clock duration.
def initialize(total = 0)
@total = total
@started = nil
end
# Start measuring a duration.
def start!
@started ||= Clock.now
end
# Stop measuring a duration and append the duration to the current total.
def stop!
if @started
@total += (Clock.now - @started)
@started = nil
end
return @total
end
# The total elapsed time including any current duration.
def total
total = @total
if @started
total += (Clock.now - @started)
end
return total
end
# Reset the total elapsed time. If the clock is currently running, reset the start time to now.
def reset!
@total = 0
if @started
@started = Clock.now
end
end
end
end