0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Goで値渡しとポイント渡しのベンチマーク比較

Posted at

条件

インライン化しないように指定(go:noinline)

下記の条件の組み合わせベンチマークテスト実行

  • ワード(1word=64bit)数 1~10
  • 関数 or 値レシーバ or ポインタレシーバ
  • 引数1~3、戻り値0~2

結果

  • ポインタのみの場合は常に一定
  • 引数と戻り値の数が少ない内は5~6ワード目まで差は小さい
  • 引数と戻り値の数が多くなると2ワード目からでも2倍程度の差になる
  • 2ワード以上の場合は素直にポインタを使用するほうが無難
  • ヒープ割り当て発生時は要計測
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?