Skip to content

Commit

Permalink
chore: adding typediff crate (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
notalfredo authored Jul 2, 2023
1 parent fc376fb commit 57641d5
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crates/semantic_typediff/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "semantic-typediff-rs"
version = "0.0.0"
authors = [
"Samantha Nguyen, <[email protected]>",
"Alfredo Gutierrez <[email protected]>"
]
description = "Provies semantic diffing"
repository = "https://github.com/nlp-rs/typediff.git"
readme = "README.md"
keywords = ["nlp", "lemma", "morphemes", "nouns",]
categories = ["data-structures", "algorithms", "text-processing", "text-editors"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.63.0"

[dev-dependencies]
criterion = { version = "0.4.0", features = ["html_reports"] }
iai = "0.1.0"

# criterion benchmarks
[[bench]]
path = "benches/criterion/fibb.rs"
name = "criterion_fibb"
harness = false

# iai benchmarks
[[bench]]
path = "benches/iai/fibb.rs"
name = "iai_fibb"
harness = false
5 changes: 5 additions & 0 deletions crates/semantic_typediff/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# semantic_typediff
[![License](https://img.shields.io/badge/license-MIT%20%26%20Apache%202.0-green)](#license)
[![CI](https://github.com/nlp-rs/typediff/actions/workflows/main.yml/badge.svg)](https://github.com/nlp-rs/typediff/actions/workflows/main.yml)
[![Security audit](https://github.com/nlp-rs/typediff/actions/workflows/security-audit.yml/badge.svg)](https://github.com/nlp-rs/typediff/actions/workflows/security-audit.yml)
> warning: **typediff is currently experimental**
17 changes: 17 additions & 0 deletions crates/semantic_typediff/benches/criterion/fibb.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[inline]
fn fibonacci(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci(n - 1) + fibonacci(n - 2),
}
}

pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
19 changes: 19 additions & 0 deletions crates/semantic_typediff/benches/iai/fibb.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use iai::{black_box, main};

fn fibonacci(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci(n - 1) + fibonacci(n - 2),
}
}

fn iai_benchmark_short() -> u64 {
fibonacci(black_box(10))
}

fn iai_benchmark_long() -> u64 {
fibonacci(black_box(30))
}

main!(iai_benchmark_short, iai_benchmark_long);
3 changes: 3 additions & 0 deletions crates/semantic_typediff/fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
corpus
artifacts
25 changes: 25 additions & 0 deletions crates/semantic_typediff/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "rust-template-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.rust-template]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "fuzz_target_1"
path = "fuzz_targets/fuzz_target_1.rs"
test = false
doc = false
6 changes: 6 additions & 0 deletions crates/semantic_typediff/fuzz/fuzz_targets/fuzz_target_1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
// fuzzed code goes here
});
1 change: 1 addition & 0 deletions crates/semantic_typediff/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#![doc = include_str!("../README.md")]

0 comments on commit 57641d5

Please sign in to comment.