61 lines
2.2 KiB
C
61 lines
2.2 KiB
C
// Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
// See LICENSE.md for license information.
|
|
// SPDX-License-Identifier: MIT
|
|
//
|
|
// toolUberLog.h - UBER's log (joeylog.txt) for the JoeyLib host tools that
|
|
// compare and tabulate it (diffUberHashes, diffUberPerf, uberPerfTable).
|
|
//
|
|
// examples/uber writes a line for each timed op and each correctness check,
|
|
// found anywhere in a line of the log:
|
|
// UBER: drawCircle r=80: 56 iters / 4 frames = 840 ops/sec | hash=A1B2C3D4
|
|
// UBER-CHK: edge-drawRect: hash=A1B2C3D4
|
|
// Each space there is any run of whitespace, the op is all up to its colon
|
|
// (the whitespace round it dropped), and the first place in a line where
|
|
// the whole form fits is the one read. Lines end in "\n" or "\r\n". Runs may
|
|
// be concatenated in one log (joeyLog appends): an op keeps the place it
|
|
// first had and takes its last line's values, those of the most recent run.
|
|
|
|
#ifndef TOOL_UBER_LOG_H
|
|
#define TOOL_UBER_LOG_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
|
|
// What a log is read for.
|
|
typedef enum ToolUberReadE {
|
|
TOOL_UBER_PERF = 0, // the timed ops' ops/sec (the hash may be left off)
|
|
TOOL_UBER_HASH // the timed ops' hashes, and the checks' as "chk:<op>"
|
|
} ToolUberReadE;
|
|
|
|
// An op: its name (nameLen bytes, a zero byte after) and its ops/sec or
|
|
// its hash (upper case).
|
|
typedef struct ToolUberOpT {
|
|
char *name;
|
|
size_t nameLen;
|
|
uint64_t opsPerSec;
|
|
char *hash;
|
|
} ToolUberOpT;
|
|
|
|
// A log's ops in the order they first appear.
|
|
typedef struct ToolUberLogT {
|
|
ToolUberOpT *ops;
|
|
size_t count;
|
|
size_t cap;
|
|
} ToolUberLogT;
|
|
|
|
// The op of that name, or NULL.
|
|
const ToolUberOpT *toolUberFind(const ToolUberLogT *log, const char *name, size_t nameLen);
|
|
|
|
// Read a log; false, with errno set, when it cannot be read.
|
|
bool toolUberLoad(const char *path, ToolUberReadE what, ToolUberLogT *log);
|
|
|
|
// Write an op's name as it is.
|
|
void toolUberNamePrint(FILE *f, const ToolUberOpT *op);
|
|
|
|
// toolUberLoad, writing "<toolName>: cannot read <path>: <reason>" to
|
|
// stderr when the log cannot be read.
|
|
bool toolUberRead(const char *toolName, const char *path, ToolUberReadE what, ToolUberLogT *log);
|
|
|
|
#endif
|