Created
April 5, 2022 19:06
-
-
Save bketelsen/2d12cdebe0e03a563862a27096f6a65d to your computer and use it in GitHub Desktop.
benchmark_template.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | |
use bartholomew::content::Content; | |
use std::path::PathBuf; | |
fn doit(n: u64) -> Result<(), anyhow::Error> { | |
let doc: String = r#"title = "The Goals of Bartholomew" | |
description = "We have plans. Big plans. Actually, they're small plans." | |
date = "2021-12-23T17:05:19Z" | |
tags = ["bartholomew"] | |
[extra] | |
author = "Matt Butcher" | |
author_page = "/author/butcher" | |
--- | |
Bartholomew is intended to be three things: | |
1. A simple-to-use CMS-like system that feels like Jekyll or other static site generators | |
2. A flexible system that is cheap to run, but easy to extend. (Cloud is expensive!) | |
3. An exhibition of the value of WebAssembly on the server-side | |
Static site generators are great for many things. But they are also limiting. To keep | |
a site feeling fresh, you have to keep building and publishing the site because all | |
elements are rendered at build time. If you want to write dynamic elements of any sort, | |
you have to resort to JavaScript. | |
But at the same time, these static site generators are super easy to use. Content is | |
just written in plain text, and is rendered into HTML. Menus and navigation are | |
built up automatically. And dealing with images and other files is as easy as dropping | |
a file in a directory. We love that experience. So we tried to combine the best of the | |
static site generator with a server-side technology. | |
{{ alert "warning" "Bartholomew is a work in progress" }}"#.to_string(); | |
let script_path = PathBuf::from("./shortcodes/"); | |
let contents: Content = doc.parse()?; | |
let mut c = Content::new(contents.head, contents.body, script_path); | |
let _out = c.render_markdown(); | |
Ok(()) | |
} | |
fn criterion_benchmark(c: &mut Criterion) { | |
c.bench_function("render content template", |b| b.iter(|| doit(black_box(1)))); | |
} | |
criterion_group!(benches, criterion_benchmark); | |
criterion_main!(benches); |
Author
bketelsen
commented
Apr 5, 2022
using two Content structs because the script path is different inside WASI.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment