Generate related posts based on tags. Sort by the number of shared tags.
Read the posts JSON file.
Iterate over the posts and populate a map containing: tag -> List<Post>
that has that tag
Iterate over the posts and for each post:
Create a map: Post -> int
to track the number of shared tags
For each tag, Iterate over the posts that have that tag
For each post, increment the shared tag count in the map.
Sort the related posts by the number of shared tags.
Write the top 5 related posts for each post to a new JSON file.
. /run. sh go | rust | python | all
Updated Results from github workflow (raw data )
Language
Processing Time
Total (PT + I/O)
Go Concurrent
20.64ms
62.0 ms
Rust Rayon
21.75ms
42.7 ms
Go
38.14ms
77.7 ms
Rust
40.24ms
62.3 ms
Crystal
65.63ms
128.4 ms
Java (GraalVM)
66.15ms
105.8 ms
Vlang
69.29ms
443.1 ms
Swift
69.72ms
568.9 ms
Odin
74.11ms
366.6 ms
Zig
224.77ms
277.4 ms
Dart VM
269.75ms
847.0 ms
Java (JIT)
305.08ms
624.6 ms
JS (Node)
340.80ms
479.3 ms
JS (Deno)
388.60ms
516.7 ms
Dart AOT
470.25ms
651.4 ms
Julia v2
795.67ms
6.071 s
JS (Bun)
985.80ms
1.083 s
Numpy
1.18s
1.662 s
Python
3.39s
3.749 s
Old Results (on my machine)
Language
Processing Time
Total (+ I/O)
Details
Rust
-
4.5s
Initial
Rust v2
-
2.60s
Replace std HashMap with fxHashMap by phazer99
Rust v3
-
1.28s
Preallocate and reuse map and unstable sort by vdrmn and Darksonn
Rust v4
-
0.13s
Use Post index as key instead of Pointer and Binary Heap by RB5009
Rust v5
38ms
52ms
Rm hashing from loop and use vec[count] instead of map[index]count by RB5009
Rust v6
23ms
36ms
Optimized Binary Heap Ops by scottlamb
Rust Rayon
9ms
22ms
Parallelize by masmullin2000
Rust Rayon
8ms
22ms
Remove comparison out of hot loop
⠀
⠀
⠀
⠀
Go
-
1.5s
Initial
Go v2
-
80ms
Add rust optimizations
Go v3
56ms
70ms
Use goccy/go-json
Go v3
34ms
55ms
Use generic binaryheap by DrBlury
Go v4
26ms
50ms
Replace binary heap with custom priority queue
Go v5
20ms
43ms
Remove comparison out of hot loop
Go Con
10ms
33ms
Go concurrency by tirprox and DrBlury
Go Con v2
5ms
29ms
Use arena, use waitgroup, rm binheap by DrBlury
⠀
⠀
⠀
⠀
Python
-
7.81s
Initial
Python v2
1.35s
1.53s
Add rust optimizations by dave-andersen
Numpy
0.57s
0.85s
Numpy implementation by Copper280z
⠀
⠀
⠀
⠀
Crystal
50ms
96ms
Inital w/ previous optimizations
Crystal v2
33ms
72ms
Replace binary heap with custom priority queue
⠀
⠀
⠀
⠀
Odin
110ms
397ms
Ported from golang code
Odin v2
104ms
404ms
Remove comparison out of hot loop
⠀
⠀
⠀
⠀
Dart VM
125ms
530ms
Ported frog golang code
Dart bin
274ms
360ms
Compiled executable
⠀
⠀
⠀
⠀
Vlang
339ms
560ms
Ported from golang code
⠀
⠀
⠀
⠀
Zig
80ms
110ms
Provided by akhildevelops