?
Unknown Status unknown.
Code
// Test profile meta-type - performance profiling with timing
// Shows profiling metadata capture with runtime timestamps
const std = @import("std");
~import std/taps
~tor hello {}
~tor goodbye {}
~tor profiler { source: string, branch: string, destination: ?[]const u8, timestamp_ns: i128 }
~proc hello|zig {
std.debug.print("Hello executed\n", .{});
}
~proc goodbye|zig {
std.debug.print("Goodbye executed\n", .{});
}
~proc profiler|zig {
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});
}
}
// 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(p.source, p.branch, p.destination, p.timestamp_ns)
~hello() |> goodbye()
Flows
flow ~tap click a branch to expand · @labels scroll to their anchor
tap (* -> *)
flow ~hello click a branch to expand · @labels scroll to their anchor
hello
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Post-validation for Profile metatype runtime test
# Validates that runtime timestamps are captured and output is correct
# Check that actual.txt exists
if [ ! -f actual.txt ]; then
echo "ERROR: actual.txt not found"
exit 1
fi
# Expected output pattern (timestamps will vary):
# Hello executed
# Profile: input:hello.__void -> input:goodbye @ <non-zero timestamp>
# Goodbye executed
# Profile: input:goodbye.__void -> terminal @ <non-zero timestamp>
# Check for event execution messages
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
# Check for Profile messages with correct transitions (with module qualifiers)
if ! grep -q "Profile: input:hello\.__void -> input:goodbye @" actual.txt; then
echo "ERROR: Missing 'Profile: input:hello.__void -> input:goodbye' transition"
exit 1
fi
if ! grep -q "Profile: input:goodbye\.__void -> terminal @" actual.txt; then
echo "ERROR: Missing 'Profile: input:goodbye.__void -> terminal' transition"
exit 1
fi
# Extract timestamps and verify they're non-zero (proving runtime capture)
TIMESTAMP1=$(grep "Profile: input:hello\.__void -> input:goodbye @" actual.txt | sed 's/.*@ //')
TIMESTAMP2=$(grep "Profile: input:goodbye\.__void -> terminal @" actual.txt | sed 's/.*@ //')
if [ -z "$TIMESTAMP1" ] || [ "$TIMESTAMP1" = "0" ]; then
echo "ERROR: First timestamp is zero or missing (expected runtime capture)"
exit 1
fi
if [ -z "$TIMESTAMP2" ] || [ "$TIMESTAMP2" = "0" ]; then
echo "ERROR: Second timestamp is zero or missing (expected runtime capture)"
exit 1
fi
# Success! Runtime profiling is working correctly
echo "✓ All Profile messages present"
echo "✓ Transitions correct (input:hello→input:goodbye→terminal)"
echo "✓ Runtime timestamps captured (non-zero values)"
exit 0