This file contains 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
/// Calls `dot -Tsvg` and passes in the contents of dot_content via stdin. | |
/// | |
/// The output is read back to a string and returned. | |
pub fn generate_svg_with_dot(dot_content: String, dot_path: Option<OsString>) -> Result<String, Box<dyn Error>> { | |
let dot_path = dot_path.unwrap_or_else(|| "dot".into()); | |
let mut child = Command::new(dot_path) | |
// .arg("-Tpng") | |
.arg("-Tsvg") | |
.stdin(Stdio::piped()) | |
.stdout(Stdio::piped()) |
This file contains 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
$ cargo run --release -- --bench | |
Compiling leading_zero_bench v0.1.0 (/home/seph/temp/leading_zero_bench) | |
Finished `release` profile [optimized] target(s) in 0.51s | |
Running `target/release/leading_zero_bench --bench` | |
lz time: [87.799 µs 87.983 µs 88.223 µs] | |
lz_branchless time: [27.554 µs 27.581 µs 27.611 µs] | |
This file contains 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
-------------------------------------------------------------------------------- | |
Command: target/profiling/am-repro | |
Massif arguments: --time-unit=B | |
ms_print arguments: massif.out.9109 | |
-------------------------------------------------------------------------------- | |
GB | |
12.66^ # | |
| @@@# |
This file contains 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
-------------------------------------------------------------------------------- | |
Command: target/profiling/am-repro | |
Massif arguments: (none) | |
ms_print arguments: massif.out.3715 | |
-------------------------------------------------------------------------------- | |
MB | |
45.81^ # | |
| @@#: |
This file contains 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
from dataclasses import dataclass | |
from enum import Enum | |
import heapq | |
Version = set[int] # The numbers in this set are indexes into the list of events in the graph. | |
@dataclass | |
class GraphEntry: | |
parents: set[int] # Set of indexes... | |
id: any |
This file contains 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
[package] | |
name = "automerge-test" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
automerge = "0.4.1" | |
serde = { version = "1.0.160", features = ["derive"] } |
This file contains 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
~/temp $ mkdir a | |
~/temp $ cd a | |
~/temp/a $ git init | |
Initialized empty Git repository in /home/seph/temp/a/.git/ | |
~/temp/a:master ✓ $ cat > foo | |
asdf | |
~/temp/a:master ✓ $ git add foo | |
~/temp/a:master ✗ $ git commit -m 'initial import' | |
[master (root-commit) 7fe725a] initial import |
This file contains 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 std::collections::HashMap; | |
use std::fmt::{Debug, Formatter}; | |
use std::hash::Hash; | |
// Wrapper around u16. Using the lowest significant 9 bits to store a 3x3 state. | |
#[derive(Copy, Clone, Eq, PartialEq, Default, Hash)] | |
struct Bits(u16); | |
fn main() { | |
let mut map = HashMap::new(); |
This file contains 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
// Read in a patch file and check that the patches all apply correctly. | |
// Run with node --expose-gc (file) using input files from here: | |
// https://github.com/josephg/crdt-benchmarks | |
const fs = require('fs') | |
const assert = require('assert') | |
const zlib = require('zlib') | |
const v8 = require('v8') | |
const Rope = require('jumprope') |
This file contains 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
type Item = null | string | number | boolean | Item[] | {[k: string]: Item}; | |
// Must match the shape of the data | |
type Version = number | [number, Version[]] | [number, {[k: string]: Version}]; | |
type Path = (string | number)[] | |
interface Doc { | |
data: Item, | |
versions: Version, |
NewerOlder