Ìwòrì 0110

The Cycle — Time/Iteration

Timestamps, elapsed time, ranges

Methods

now / bayi / timestamp

Iwori.now() ? Int

Get current Unix timestamp in seconds.

ayanmo start = Iwori.now();
// ... do work ...
ayanmo end = Iwori.now();
Irosu.fo("Duration:");
Irosu.fo(end - start);

now_ms / bayi_ms

Iwori.now_ms() ? Int

Get current Unix timestamp in milliseconds.

ayanmo precise = Iwori.now_ms();
Irosu.fo("Milliseconds:");
Irosu.fo(precise);

elapsed / aago

Iwori.elapsed(start_ms: Int) ? Int

Get elapsed time from start in milliseconds.

ayanmo start = Iwori.now_ms();
// ... operation ...
ayanmo elapsed = Iwori.elapsed(start);
Irosu.fo("Took ms:");
Irosu.fo(elapsed);

format / ?e_?j? / iso

Iwori.format(timestamp: Int) ? String

Format timestamp to string.

ayanmo ts = Iwori.now();
ayanmo formatted = Iwori.format(ts);
Irosu.fo(formatted);

parse / ka_?j?

Iwori.parse(datestr: String) ? Int

Parse date string to timestamp.

ayanmo ts = Iwori.parse("1704067200");
Irosu.fo(ts);

range / laarin

Iwori.range(start: Int, end: Int) ? List

Create a range of numbers for iteration.

ayanmo numbers = Iwori.range(0, 5);
// [0, 1, 2, 3, 4]

fun i ninu Iwori.range(1, 10) {
    Irosu.fo(i);
}

Example: Performance Timing

// Measure operation time
ayanmo start = Iwori.now_ms();

// Do some work
ayanmo sum = 0;
fun i ninu Iwori.range(0, 1000000) {
    ayanmo sum = sum + i;
}

ayanmo elapsed = Iwori.elapsed(start);
Irosu.fo("Sum:");
Irosu.fo(sum);
Irosu.fo("Time (ms):");
Irosu.fo(elapsed);