SHARE
TWEET

Untitled

a guest Oct 9th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function makeid() {
  2.   var text = "";
  3.   var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  4.  
  5.   for (var i = 0; i < 10; i++)
  6.     text += possible.charAt(Math.floor(Math.random() * possible.length));
  7.  
  8.   return text;
  9. }
  10.  
  11.  
  12. const hashChains = new HashTableChains();
  13. const hashLinear = new HashTableLinearP();
  14.  
  15. var keys = [];
  16. var values = [];
  17.  
  18. for (var i = 0; i < 10; i++){
  19.     keys.push(makeid());
  20.     values.push(Math.round(i));
  21. }
  22.  
  23. console.time("Chains");
  24. for (var i = 0;i < keys.length;i++){
  25.     hashChains.putChain(keys[i], values[i]);
  26. }
  27. console.timeEnd("Chains");
  28.  
  29. console.time("LinearP");
  30. for (var i = 0;i < keys.length;i++){
  31.     hashLinear.putLinearP(keys[i], values[i]);
  32. }
  33. console.timeEnd("LinearP");
  34.  
  35. // Chains: 0.539ms
  36. // LinearP: 0.071ms
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top