Sample code for 30+ languages & platforms
Zig

Measure Elapsed Time with the Convenience Timer

See more Socket/SSL/TLS Examples

Demonstrates Socket.StartTiming, which starts or restarts the object's convenience timer. The ElapsedSeconds property then reports the whole number of seconds since the call.

Background. This timer is a convenience for measuring durations and does not affect connection behavior or timeouts.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main() !void {
    const socket = try chilkat.Socket.init();
    defer socket.deinit();

    // Start (or restart) the object's convenience timer.
    socket.startTiming();

    // Perform some work.  (Here the thread simply sleeps to let time pass.)
    socket.sleepMs(1500);

    // Read the whole number of seconds elapsed since StartTiming was called.
    std.debug.print("Elapsed seconds: {d}\n", .{socket.getElapsedSeconds()});
}