SHARE
TWEET

Untitled

a guest Dec 12th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var db = connect('localhost:27017/aggr-test'),
  2.     opts = {
  3.         startTime: new Date('01/01/2011').getTime(),
  4.         endTime: new Date('01/01/2012').getTime(),
  5.         numEvents: 500 * 1000
  6.     },
  7.     eventTime = opts.startTime,
  8.     incrementMs = (opts.endTime - opts.startTime) / opts.numEvents;
  9.  
  10. function getEvent() {
  11.     var event = {
  12.         ts: eventTime,
  13.         dat1: Math.random() * 1 * 1000,
  14.         dat2: Math.random() * 2 * 1000,
  15.         dat3: Math.random() * 3 * 1000,
  16.         dat4: Math.random() * 4 * 1000,
  17.         dat5: Math.random() * 5 * 1000,
  18.         dat6: Math.random() * 6 * 1000,
  19.         dat7: Math.random() * 7 * 1000,
  20.         dat8: Math.random() * 8 * 1000,
  21.         dat9: Math.random() * 9 * 1000,
  22.         dat10: Math.random() * 10 * 1000
  23.     };
  24.  
  25.     eventTime += incrementMs;
  26.    
  27.     return event;
  28. }
  29.  
  30. print('Dropping database...');
  31. db.dropDatabase();
  32.  
  33. print('Inserting test data...');
  34. var insertStart = Date.now();
  35. for (var i = 0; i < opts.numEvents; i++) {
  36.     (i + 1) % 10000 || print(i + 1 + ' events created');
  37.     db.events.insert(getEvent());
  38. }
  39. var insertDuration = ((Date.now() - insertStart) / 1000).toFixed(2);
  40. print('Inserted ' + opts.numEvents + ' events (' + insertDuration  + ' seconds)');
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