Skip to content

Commit 54dc319

Browse files
authored
Merge branch 'main' into update_csharp
2 parents 5e4e795 + f2172e6 commit 54dc319

File tree

9 files changed

+149
-5
lines changed

9 files changed

+149
-5
lines changed

.github/odin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -euo pipefail
44

5-
VERSION=dev-2023-05
5+
VERSION=dev-2024-01
66
FILE_NAME=odin-ubuntu-amd64-$VERSION.zip
77
sudo apt-get install -y aria2
88
mkdir /tmp/odin

bench/algorithm/json-serde/4-i.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use serde::{Deserialize, Serialize, Serializer};
2+
use std::fs;
3+
4+
fn main() -> anyhow::Result<()> {
5+
let file_name = std::env::args_os()
6+
.nth(1)
7+
.and_then(|s| s.into_string().ok())
8+
.unwrap_or("sample".to_string());
9+
let n = std::env::args_os()
10+
.nth(2)
11+
.and_then(|s| s.into_string().ok())
12+
.and_then(|s| s.parse().ok())
13+
.unwrap_or(10);
14+
let mut json_str = fs::read(format!("{}.json", file_name))?;
15+
let json: GeoData = simd_json::from_slice(&mut json_str)?;
16+
17+
print_hash(simd_json::to_vec(&json)?);
18+
let mut array = Vec::with_capacity(n);
19+
for _i in 0..n {
20+
let json: GeoData = simd_json::from_slice(&mut json_str)?;
21+
array.push(json);
22+
}
23+
print_hash(simd_json::to_vec(&array)?);
24+
Ok(())
25+
}
26+
27+
fn print_hash(bytes: impl AsRef<[u8]>) {
28+
let digest = md5::compute(&bytes);
29+
println!("{:x}", digest);
30+
}
31+
32+
#[derive(Deserialize, Debug, Default)]
33+
struct MyF64(f64);
34+
35+
impl Serialize for MyF64 {
36+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
37+
where
38+
S: Serializer,
39+
{
40+
if self.0.fract() == 0.0 {
41+
serializer.serialize_i64(self.0 as i64)
42+
} else {
43+
serializer.serialize_f64(self.0)
44+
}
45+
}
46+
}
47+
48+
#[derive(Deserialize, Serialize, Debug, Default)]
49+
struct GeoData {
50+
r#type: String,
51+
features: Vec<Feature>,
52+
}
53+
54+
#[derive(Deserialize, Serialize, Debug, Default)]
55+
struct Feature {
56+
r#type: String,
57+
properties: Properties,
58+
geometry: Geometry,
59+
}
60+
61+
#[derive(Deserialize, Serialize, Debug, Default)]
62+
struct Properties {
63+
name: String,
64+
}
65+
66+
#[derive(Deserialize, Serialize, Debug, Default)]
67+
struct Geometry {
68+
r#type: String,
69+
coordinates: Vec<Vec<[MyF64; 2]>>,
70+
}

bench/algorithm/json-serde/5-i.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use serde::{Deserialize, Serialize, Serializer};
2+
use std::fs;
3+
4+
fn main() -> anyhow::Result<()> {
5+
let file_name = std::env::args_os()
6+
.nth(1)
7+
.and_then(|s| s.into_string().ok())
8+
.unwrap_or("sample".to_string());
9+
let n = std::env::args_os()
10+
.nth(2)
11+
.and_then(|s| s.into_string().ok())
12+
.and_then(|s| s.parse().ok())
13+
.unwrap_or(10);
14+
let mut json_str = fs::read(format!("{}.json", file_name))?;
15+
let json: GeoData = sonic_rs::from_slice(&mut json_str)?;
16+
17+
print_hash(sonic_rs::to_vec(&json)?);
18+
let mut array = Vec::with_capacity(n);
19+
for _i in 0..n {
20+
let json: GeoData = sonic_rs::from_slice(&mut json_str)?;
21+
array.push(json);
22+
}
23+
print_hash(sonic_rs::to_vec(&array)?);
24+
Ok(())
25+
}
26+
27+
fn print_hash(bytes: impl AsRef<[u8]>) {
28+
let digest = md5::compute(&bytes);
29+
println!("{:x}", digest);
30+
}
31+
32+
#[derive(Deserialize, Debug, Default)]
33+
struct MyF64(f64);
34+
35+
impl Serialize for MyF64 {
36+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
37+
where
38+
S: Serializer,
39+
{
40+
if self.0.fract() == 0.0 {
41+
serializer.serialize_i64(self.0 as i64)
42+
} else {
43+
serializer.serialize_f64(self.0)
44+
}
45+
}
46+
}
47+
48+
#[derive(Deserialize, Serialize, Debug, Default)]
49+
struct GeoData {
50+
r#type: String,
51+
features: Vec<Feature>,
52+
}
53+
54+
#[derive(Deserialize, Serialize, Debug, Default)]
55+
struct Feature {
56+
r#type: String,
57+
properties: Properties,
58+
geometry: Geometry,
59+
}
60+
61+
#[derive(Deserialize, Serialize, Debug, Default)]
62+
struct Properties {
63+
name: String,
64+
}
65+
66+
#[derive(Deserialize, Serialize, Debug, Default)]
67+
struct Geometry {
68+
r#type: String,
69+
coordinates: Vec<Vec<[MyF64; 2]>>,
70+
}

bench/algorithm/knucleotide/1.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ read_lines_with_buffering :: proc() ->(string,io.Error){
102102
return "",io.Error(err)
103103
}
104104
defer os.close(f)
105-
bufio.reader_init_with_buf(&r, {os.stream_from_handle(f)}, buffer[:])
105+
bufio.reader_init_with_buf(&r, os.stream_from_handle(f), buffer[:])
106106
defer bufio.reader_destroy(&r)
107107

108108
linerc:strings.Builder;

bench/algorithm/mandelbrot/1.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package main
22

3-
import "core:crypto/md5"
3+
import "core:crypto/legacy/md5"
44
import "core:fmt"
55
import "core:runtime"
66
import "core:strconv"

bench/bench_odin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ environments:
3838
build: odin build . -o:speed -disable-assert -no-bounds-check -microarch:broadwell -show-timings -out:out/app
3939
out_dir: out
4040
run_cmd: app
41-
allow_failure: true
41+
# allow_failure: true

bench/bench_ruby.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ environments:
7171
- os: linux
7272
compiler: truffleruby
7373
version: latest
74-
docker: ghcr.io/graalvm/truffleruby
74+
docker: ghcr.io/graalvm/truffleruby-community
7575
docker_runtime_dir: /opt/truffleruby-*
7676
docker_runtime_dir_rename_to: truffleruby
7777
include:

bench/bench_rust.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ problems:
5959
- 1.rs
6060
- 2.rs
6161
- 3.rs
62+
- 4-i.rs
63+
- 5-i.rs
6264
- name: coro-prime-sieve
6365
source:
6466
- 1.rs

bench/include/rust/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ rayon = "1"
4242
regex = "1"
4343
serde = {version = "1", features = ["derive"]}
4444
serde_json = {version = "1", features = ["float_roundtrip", "preserve_order"]}
45+
simd-json = "0.13"
46+
sonic-rs = "0.3"
4547
static-rc = "0"
4648

4749
async-channel = {version = "2", optional = true}

0 commit comments

Comments
 (0)