(str, num)
| 14 | }) |
| 15 | |
| 16 | function stringRepeat(str, num) { |
| 17 | num = Number(num) |
| 18 | |
| 19 | var result = '' |
| 20 | while (true) { |
| 21 | if (num & 1) { // (1) |
| 22 | result += str |
| 23 | } |
| 24 | num >>>= 1 // (2) |
| 25 | if (num <= 0) break |
| 26 | str += str |
| 27 | } |
| 28 | |
| 29 | return result |
| 30 | } |
| 31 | |
| 32 | it('history implementation should be fast', function() { |
| 33 | // create an entry with a large content string (256k) and see how fast we can write and read it |