002 profile release

○ Planned This feature is planned but not yet implemented.

Feature: Profile meta-type not implemented

Code

// Test profile meta-type - performance profiling with timing
// Shows profiling metadata capture with runtime timestamps
const std = @import("std");
~import "$std/taps"

~event hello {}
| done {}

~event goodbye {}
| done {}

~[comptime|runtime] event profiler { source: []const u8, branch: []const u8, destination: ?[]const u8, timestamp_ns: i128 }
| done {}

~proc hello {
    std.debug.print("Hello executed\n", .{});
    return .{ .done = .{} };
}

~proc goodbye {
    std.debug.print("Goodbye executed\n", .{});
    return .{ .done = .{} };
}

~proc profiler {
    if (destination) |dest| {
        std.debug.print("Profile: {s}.{s} -> {s} @ {}\n", .{source, branch, dest, timestamp_ns});
    } else {
        std.debug.print("Profile: {s}.{s} -> terminal @ {}\n", .{source, branch, timestamp_ns});
    }
    return .{ .done = .{} };
}

// Universal tap using profile meta-type
// Captures source event, branch, destination, and runtime timestamp
// NOTE: Profile uses string-based fields (no enum conversion needed)
~tap(* -> *)
| Profile p |> profiler(source: p.source, branch: p.branch, destination: p.destination, timestamp_ns: p.timestamp_ns)
    | done |> _

~hello()
| done |> goodbye()
    | done |> _
input.kz

Test Configuration

MUST_RUN

Post-validation Script:

#!/bin/bash
# Post-validation for Profile metatype RELEASE mode test
# Shows actual nanosecond-level performance

# Check that actual.txt exists
if [ ! -f actual.txt ]; then
    echo "ERROR: actual.txt not found"
    exit 1
fi

# Extract and display timestamps
echo "=== RELEASE MODE PERFORMANCE ==="
TIMESTAMP1=$(grep "Profile: hello\.done -> goodbye @" actual.txt | sed 's/.*@ //')
TIMESTAMP2=$(grep "Profile: goodbye\.done -> terminal @" actual.txt | sed 's/.*@ //')

if [ -z "$TIMESTAMP1" ] || [ -z "$TIMESTAMP2" ]; then
    echo "ERROR: Could not extract timestamps"
    exit 1
fi

# Calculate time difference (in nanoseconds)
DIFF=$((TIMESTAMP2 - TIMESTAMP1))
echo "First transition:  $TIMESTAMP1 ns"
echo "Second transition: $TIMESTAMP2 ns"
echo "Time difference:   $DIFF ns ($((DIFF / 1000)) microseconds)"
echo ""

# Verify basic correctness
if ! grep -q "Hello executed" actual.txt; then
    echo "ERROR: Missing 'Hello executed' message"
    exit 1
fi

if ! grep -q "Goodbye executed" actual.txt; then
    echo "ERROR: Missing 'Goodbye executed' message"
    exit 1
fi

echo "✓ Release mode profiling working correctly"
echo "✓ Events executed with ${DIFF}ns between them"
exit 0