Skip to content

Commit 785a937

Browse files
authored
Merge branch 'main' into update_csharp
2 parents 9c2d16c + fcf02c6 commit 785a937

File tree

14 files changed

+140
-23
lines changed

14 files changed

+140
-23
lines changed

.github/workflows/bench.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
fail-fast: true
23+
# fail-fast: false
2324
matrix:
2425
os: [ubuntu-22.04]
2526
lang: [
@@ -229,10 +230,10 @@ jobs:
229230
pushd bench
230231
dotnet run -c Release --project tool -- --task test --langs ${{ matrix.lang }}
231232
popd
232-
- uses: actions/upload-artifact@v3
233+
- uses: actions/upload-artifact@v4
233234
if: github.ref == 'refs/heads/main'
234235
with:
235-
name: build
236+
name: build-${{ matrix.lang }}
236237
path: bench/build/**/*
237238
if-no-files-found: error
238239
gate:
@@ -304,9 +305,10 @@ jobs:
304305
with:
305306
ruby-version: 3 # Not needed with a .ruby-version file
306307
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
307-
- uses: actions/download-artifact@v3
308+
- uses: actions/download-artifact@v4
308309
with:
309-
name: build
310+
pattern: build-*
311+
merge-multiple: true
310312
path: bench/build/
311313
- name: Bench
312314
run: |
@@ -315,7 +317,7 @@ jobs:
315317
dotnet run -c Release --project tool -- --task test --ignore-missing
316318
dotnet run -c Release --project tool -- --task bench --ignore-missing
317319
popd
318-
- uses: actions/upload-artifact@v3
320+
- uses: actions/upload-artifact@v4
319321
with:
320322
name: log
321323
path: bench/build/_results/**/*
@@ -335,7 +337,7 @@ jobs:
335337
- uses: pnpm/action-setup@v2
336338
with:
337339
version: 9
338-
- uses: actions/download-artifact@v3
340+
- uses: actions/download-artifact@v4
339341
with:
340342
# Artifact name
341343
name: log

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _Current benchmarks problems and their implementations are from [The Computer La
5757

5858
## Prerequisites
5959

60-
[net7](https://dotnet.microsoft.com/)
60+
[net9](https://dotnet.microsoft.com/)
6161

6262
[nodejs 14](https://nodejs.org/)
6363

bench/algorithm/http-server/1-http2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn main() -> anyhow::Result<()> {
2424
.and_then(|s| s.into_string().ok())
2525
.and_then(|s| s.parse().ok())
2626
.unwrap_or(10);
27-
let mut rng = thread_rng();
28-
let port = rng.gen_range(30000..40000);
27+
let mut rng = rand::rng();
28+
let port = rng.random_range(30000..40000);
2929
tokio_main(n, port)?;
3030
std::process::exit(0);
3131
}

bench/algorithm/http-server/1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ fn main() -> anyhow::Result<()> {
1515
.and_then(|s| s.into_string().ok())
1616
.and_then(|s| s.parse().ok())
1717
.unwrap_or(10);
18-
let mut rng = thread_rng();
19-
let port = rng.gen_range(30000..40000);
18+
let mut rng = rand::rng();
19+
let port = rng.random_range(30000..40000);
2020
tokio_main(n, port)?;
2121
std::process::exit(0);
2222
}

bench/algorithm/http-server/2-http2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ fn main() -> anyhow::Result<()> {
1919
.and_then(|s| s.into_string().ok())
2020
.and_then(|s| s.parse().ok())
2121
.unwrap_or(10);
22-
let mut rng = thread_rng();
23-
let port = rng.gen_range(30000..40000);
22+
let mut rng = rand::rng();
23+
let port = rng.random_range(30000..40000);
2424
tokio_main(n, port)?;
2525
std::process::exit(0);
2626
}

bench/algorithm/http-server/2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ fn main() -> anyhow::Result<()> {
1414
.and_then(|s| s.into_string().ok())
1515
.and_then(|s| s.parse().ok())
1616
.unwrap_or(10);
17-
let mut rng = thread_rng();
18-
let port = rng.gen_range(30000..40000);
17+
let mut rng = rand::rng();
18+
let port = rng.random_range(30000..40000);
1919
tokio_main(n, port)?;
2020
std::process::exit(0);
2121
}

bench/algorithm/mandelbrot/4.cs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using System.Runtime.CompilerServices;
2+
using System.Runtime.Intrinsics;
3+
using System.Security.Cryptography;
4+
using System.Text;
5+
using System;
6+
7+
public class MandelBrot
8+
{
9+
public static void Main(string[] args)
10+
{
11+
var size = args.Length == 0 ? 200 : int.Parse(args[0]);
12+
size = (size + 7) / 8 * 8;
13+
var chunkSize = size / 8;
14+
var inv = 2.0 / size;
15+
Console.WriteLine($"P4\n{size} {size}");
16+
17+
var xloc = new Vector512<double>[chunkSize];
18+
for (var i = 0; i < chunkSize; i++)
19+
{
20+
var array = new double[8];
21+
var offset = i * 8;
22+
for (var j = 0; j < 8; j++)
23+
{
24+
array[j] = (offset + j) * inv - 1.5;
25+
}
26+
xloc[i] = Vector512.Create(array);
27+
}
28+
29+
var data = new byte[size * chunkSize];
30+
31+
for (var y = 0; y < size; y++)
32+
{
33+
var ci = y * inv - 1.0;
34+
for (var x = 0; x < chunkSize; x++)
35+
{
36+
var r = mbrot8(xloc[x], ci);
37+
if (r > 0)
38+
{
39+
data[y * chunkSize + x] = r;
40+
}
41+
}
42+
}
43+
44+
using var hasher = MD5.Create();
45+
var hash = hasher.ComputeHash(data);
46+
Console.WriteLine(ToHexString(hash));
47+
}
48+
49+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
50+
static byte mbrot8(Vector512<double> cr, double civ)
51+
{
52+
Vector512<double> ci = Vector512.Create(civ);
53+
Vector512<double> zr = Vector512.Create(0.0);
54+
Vector512<double> zi = Vector512.Create(0.0);
55+
Vector512<double> tr = Vector512.Create(0.0);
56+
Vector512<double> ti = Vector512.Create(0.0);
57+
Vector512<double> absz = Vector512.Create(0.0);
58+
59+
for (var _i = 0; _i < 10; _i++)
60+
{
61+
for (var _j = 0; _j < 5; _j++)
62+
{
63+
zi = (zr + zr) * zi + ci;
64+
zr = tr - ti + cr;
65+
tr = zr * zr;
66+
ti = zi * zi;
67+
}
68+
absz = tr + ti;
69+
var terminate = true;
70+
for (var i = 0; i < 8; i++)
71+
{
72+
if (absz[i] <= 4.0)
73+
{
74+
terminate = false;
75+
break;
76+
}
77+
}
78+
if (terminate)
79+
{
80+
return 0;
81+
}
82+
}
83+
84+
var accu = (byte)0;
85+
for (var i = 0; i < 8; i++)
86+
{
87+
if (absz[i] <= 4.0)
88+
{
89+
accu |= (byte)(0x80 >> i);
90+
}
91+
}
92+
return accu;
93+
}
94+
95+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
96+
static string ToHexString(byte[] ba)
97+
{
98+
StringBuilder hex = new StringBuilder(ba.Length * 2);
99+
foreach (byte b in ba)
100+
{
101+
hex.AppendFormat("{0:x2}", b);
102+
}
103+
return hex.ToString();
104+
}
105+
}

bench/bench_csharp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ problems:
4343
- 1.cs
4444
- 2.cs
4545
- 3.cs
46+
- 4.cs
4647
- name: json-serde
4748
source:
4849
- 1.cs

bench/bench_go_ffi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ environments:
1212
- os: linux
1313
compiler: go
1414
version: latest
15-
docker: golang:1.23
15+
docker: golang:1.24
1616
env:
1717
GOAMD64: v3 # https://github.com/golang/go/wiki/MinimumRequirements#amd64
1818
include: go

bench/bench_nim.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ problems:
2828
- 2.nim
2929
- name: http-server
3030
source:
31-
- 1.nim
31+
# - 1.nim
3232
- name: coro-prime-sieve
3333
source:
3434
- 1.nim

0 commit comments

Comments
 (0)