タグ

performanceとC++に関するNyohoのブックマーク (2)

  • 前置インクリメント vs 後置インクリメント | 闇夜のC++

    後置インクリメントにはひと目で遅くなりそうな処理が見て取れますね。 前置インクリメントがインクリメント処理後、単純に自身の参照を返すのに対し、後置インクリメントではインクリメント前に一時オブジェクトの生成、そしてインクリメント後にはその前に生成した一時オブジェクトを値で返しています。 前置と後置では、単純にオブジェクトをコピーして返す分、普通に考えたら後置の方が遅いよね。というのが従来の認識でした。 「C++ Coding Standards -101のルール、ガイドライン、ベストプラクティス」の中でも、特に後置インクリメントの必然性が無い時は迷わず前置インクリメントを使うことが推奨されてきました。 元の値を必要としないときは前置形式の演算子を使おう __C++ Coding Standards (p50) 新たな主張 「ゲームエンジン・アーキテクチャ第二版」の中の一節を紹介します。 しか

  • Swift Beta performance: sorting arrays

    I was implementing an algorithm in Swift Beta and noticed that the performance was very poor. After digging deeper I realized that one of the bottlenecks was something as simple as sorting arrays. The relevant part is here: let n = 1000000 var x = [Int](repeating: 0, count: n) for i in 0..<n { x[i] = random() } // start clock here let y = sort(x) // stop clock here In C++, a similar operation take

    Swift Beta performance: sorting arrays
  • 1