CRC32 slower than MD5 #13
	
		Labels
		
	
	
	
	
	
	
		No Milestone
		
			
		
	
	
		
		
		
			No project
			
				
			
		
	
	
	
	
	
		No Assignees
		
			
		
	
	
	
		1 Participants
		
	
	
		
		
			Notifications
			
				
			
		
	
	
	
	Due Date
	No due date set.
			
				Dependencies
				
				
		
	
	
	No dependencies set.
			Reference: sheetjs/js-crc32#13
			
		
	
		Loading…
	
		Reference in New Issue
	
	Block a user
	
	No description provided.
		
		Delete Branch "%!s()"
	 
	Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What am I missing here?
CRC constantly over 10ms while MD5 is under 5ms constantly.
You're seeing the tradeoff between a pure JS implementation and a C implementation. NodeJS
cryptomodule ultimately farms out to the OpenSSL library.There's an overhead to calling the native function, which is why for smaller sized buffers the JS approach is faster.
For larger buffers, the improved performance of the native C library exceeds the cost of switching, so even though MD5 is a slower algorithm the native approach is faster. The fact that you're starting from a Buffer means that there's an additional performance advantage for the C library (it is more efficient to read from a Buffer in C++ APIs than the JS public surface).
If you want a real apples-to-apples comparison, try comparing to a pure JS MD5 implementation like https://www.npmjs.com/package/md5.js -- from local tests MD5 is 10x slower than CRC-32