Skip to content

使用 @setFloatMode 后依然比等价的 C 代码慢很多? #204

Answered by ufbycd
w568w asked this question in 新手提问
Discussion options

You must be logged in to vote

Zig向量可解君愁,我试了下将代码改为向量化后效率高不少:
Zig 向量化修改后源码:https://0x0.st/8681.zig

# Zig 向量化
tmp=$(mktemp -t tmp.XXXXXX.zig); curl https://0x0.st/8681.zig -o "$tmp" && zig build-exe -O ReleaseFast -femit-bin=a.out "$tmp" && time ./a.out

我这里的测试结果是:

  • C(-Ofast): 0.573s
  • Zig: 1.178s
  • Zig向量化:0.548s

我的系统:

  • CPU: Intel i7-9700
  • GCC:14.2.1
  • Zig:0.14.1

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@jiacai2050
Comment options

Comment options

You must be logged in to vote
2 replies
@w568w
Comment options

@ufbycd
Comment options

Answer selected by w568w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants