GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.8 KiB

2 months ago
  1. "use strict";
  2. var float = require(".."),
  3. ieee754 = require("ieee754"),
  4. newSuite = require("./suite");
  5. var F32 = Float32Array;
  6. var F64 = Float64Array;
  7. delete global.Float32Array;
  8. delete global.Float64Array;
  9. var floatFallback = float({});
  10. global.Float32Array = F32;
  11. global.Float64Array = F64;
  12. var buf = new Buffer(8);
  13. newSuite("writeFloat")
  14. .add("float", function() {
  15. float.writeFloatLE(0.1, buf, 0);
  16. })
  17. .add("float (fallback)", function() {
  18. floatFallback.writeFloatLE(0.1, buf, 0);
  19. })
  20. .add("ieee754", function() {
  21. ieee754.write(buf, 0.1, 0, true, 23, 4);
  22. })
  23. .add("buffer", function() {
  24. buf.writeFloatLE(0.1, 0);
  25. })
  26. .add("buffer (noAssert)", function() {
  27. buf.writeFloatLE(0.1, 0, true);
  28. })
  29. .run();
  30. newSuite("readFloat")
  31. .add("float", function() {
  32. float.readFloatLE(buf, 0);
  33. })
  34. .add("float (fallback)", function() {
  35. floatFallback.readFloatLE(buf, 0);
  36. })
  37. .add("ieee754", function() {
  38. ieee754.read(buf, 0, true, 23, 4);
  39. })
  40. .add("buffer", function() {
  41. buf.readFloatLE(0);
  42. })
  43. .add("buffer (noAssert)", function() {
  44. buf.readFloatLE(0, true);
  45. })
  46. .run();
  47. newSuite("writeDouble")
  48. .add("float", function() {
  49. float.writeDoubleLE(0.1, buf, 0);
  50. })
  51. .add("float (fallback)", function() {
  52. floatFallback.writeDoubleLE(0.1, buf, 0);
  53. })
  54. .add("ieee754", function() {
  55. ieee754.write(buf, 0.1, 0, true, 52, 8);
  56. })
  57. .add("buffer", function() {
  58. buf.writeDoubleLE(0.1, 0);
  59. })
  60. .add("buffer (noAssert)", function() {
  61. buf.writeDoubleLE(0.1, 0, true);
  62. })
  63. .run();
  64. newSuite("readDouble")
  65. .add("float", function() {
  66. float.readDoubleLE(buf, 0);
  67. })
  68. .add("float (fallback)", function() {
  69. floatFallback.readDoubleLE(buf, 0);
  70. })
  71. .add("ieee754", function() {
  72. ieee754.read(buf, 0, true, 52, 8);
  73. })
  74. .add("buffer", function() {
  75. buf.readDoubleLE(0);
  76. })
  77. .add("buffer (noAssert)", function() {
  78. buf.readDoubleLE(0, true);
  79. })
  80. .run();