多种语言数据处理性能基准测试 (Rust, Go, Swift, Zig, Julia 等)
Data Processing Benchmark Featuring Rust, Go, Swift, Zig, Julia etc.

原始链接: https://github.com/zupat/related_post_gen

该基准测试比较了多种语言——Rust、Go、Python、Crystal、Odin、Dart、Vlang 和 Zig——在特定任务上的性能,展示了显著的优化进展。 最初,Rust 耗时 4.5 秒,但通过迭代改进,包括替换 HashMap、预分配和键/数据结构更改,将其降低到惊人的 **8 毫秒**,并使用了 Rayon 并行化。Go 从 1.5 秒开始,通过并发和自定义数据结构等优化,达到 **5 毫秒**。 Python 获得了显著提升,通过 Numpy 实现,从 7.81 秒下降到 **0.57 秒**。Crystal 达到 **33 毫秒**,而 Odin 和 Dart 仍然较慢,分别为 **104 毫秒**和 **125 毫秒**。Vlang 和 Zig 表现出适度的性能,分别为 **339 毫秒**和 **80 毫秒**。 关键的优化措施始终包括用更高效的替代方案替换标准数据结构(如 HashMaps 和二叉堆),从关键循环中删除比较,并在可能的情况下利用并行处理。

## 数据处理语言基准测试总结 一项新的基准测试,比较了Rust、Go、Swift、Zig、Julia、Java、C++、C#和Python等语言的数据处理性能,在Hacker News上引发了讨论。虽然该基准测试提供了一个比较的起点,但评论员强调了其方法论存在显著的局限性。 提出的问题包括次优的编译器标志(特别是Java的GC)、不一致的代码质量、可能过时的语言版本,以及缺乏对操作系统缓存和I/O性能等因素的控制。多位用户指出,实现准确的语言基准测试非常复杂,并且高度依赖于数据集和实现细节。 尽管存在这些批评,结果显示出有趣的趋势。Julia的性能显著优于Python,并且利用SIMD和内存跨度的现代C#展现出令人印象深刻的速度。经常被忽视的D语言也被认为是强大的竞争者。该基准测试还引发了关于NumPy和Numba等库对于优化Python性能的重要性讨论。最终,共识是原始语言速度并非全部,生态系统、开发者体验和特定工作负载需求是至关重要的考虑因素。
相关文章

原文
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 from golang code Dart bin 274ms 360ms Compiled executable ⠀ ⠀ ⠀ ⠀ Vlang 339ms 560ms Ported from golang code ⠀ ⠀ ⠀ ⠀ Zig 80ms 110ms Provided by akhildevelops
联系我们 contact @ memedata.com