Performance Comparison: SHA-512 is 12-27% faster than SHA-256

Performance Comparison: SHA-512 is 12-27% faster than SHA-256

When it comes to hashing algorithms, the choice between SHA-512 and SHA-256 can have an impact on performance. A recent test conducted on a MacBook Pro (Mid 2015) with a 2.5 GHz Intel Core i7 processor running Node.js v9.2.0 revealed interesting results.

The test measured the time taken to hash data using both SHA-512 and SHA-256 algorithms, with varying block sizes. Here are the findings:

  • Block Size: 8192
    • Hashing SHA-512 x 300,000 times: 4,447ms
    • Hashing SHA-256 x 300,000 times: 6,105ms
    • Difference: 27.16%
  • Block Size: 4096
    • Hashing SHA-512 x 300,000 times: 2,601ms
    • Hashing SHA-256 x 300,000 times: 3,426ms
    • Difference: 24.08%
  • Block Size: 1024
    • Hashing SHA-512 x 300,000 times: 1,218ms
    • Hashing SHA-256 x 300,000 times: 1,434ms
    • Difference: 15.06%
  • Block Size: 512
    • Hashing SHA-512 x 300,000 times: 970ms
    • Hashing SHA-256 x 300,000 times: 1,102ms
    • Difference: 11.98%

Test Results

Based on these results, it is evident that SHA-512 consistently outperformed SHA-256 in terms of speed. The performance advantage ranged from 11.98% with a block size of 512 to a significant 27.16% with a block size of 8192.

It's important to note that these findings were specific to the tested environment, which included a MacBook Pro (Mid 2015) with a 2.5 GHz Intel Core i7 processor and Node.js v9.2.0. Different hardware configurations and software versions may yield varying results.

Ultimately, the choice between SHA-512 and SHA-256 depends on various factors such as security requirements, compatibility, and performance considerations. These test results can serve as a reference point for developers when selecting the appropriate hashing algorithm for their specific use cases.

References

Please refer to the provided gist for the detailed test results and further information.

Enjoyed the read?

Don’t miss out on my next article! to stay updated on the latest insights.

Need advice on your startup?

I’m available for interesting web projects. Send me some details and let’s start working!

Hire me
avataravataravataravataravatar

Let’s stay in touch!

Join 50+ other developers who receive my thoughts, ideas, and favorite links.