sightglass_api/lib.rs
1//! This crate provides simple bindings for Rust to the Sightglass API. The primary intent is to
2//! make it easy to instrument Rust code that will be compiled to Wasm and measured with Sightglass.
3//!
4//! For example:
5//! ```
6//! use sightglass_api as bench;
7//! bench::start();
8//! let work = 42 * 42;
9//! bench::end();
10//! ```
11//!
12//! See [benchmarks-next/README.md] for more details.
13
14mod ffi {
15 #[link(wasm_import_module = "bench")]
16 extern "C" {
17 pub fn start();
18 pub fn end();
19 }
20}
21
22/// Call this once to end sightglass recording. When compiled to Wasm, the import will look
23/// like `(import "bench" "end" (...))`.
24pub fn start() {
25 unsafe {
26 ffi::start();
27 }
28}
29
30/// Call this once to start sightglass recording. When compiled to Wasm, the import will look
31/// like `(import "bench" "start" (...))`.
32pub fn end() {
33 unsafe {
34 ffi::end();
35 }
36}