A Twitch.tv viewer reward and games system.
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.

42 lines
845 B

12 years ago
  1. var common = require('../test/common');
  2. var client = common.createConnection({typeCast: false});
  3. var rowsPerRun = 100000;
  4. client.connect(function(err) {
  5. if (err) throw err;
  6. client.query('USE node_mysql_test', function(err, results) {
  7. if (err) throw err;
  8. selectRows();
  9. });
  10. });
  11. var firstSelect;
  12. var rowCount = 0;
  13. console.error('Benchmarking rows per second in hz:');
  14. function selectRows() {
  15. firstSelect = firstSelect || Date.now();
  16. client.query('SELECT * FROM posts', function(err, rows) {
  17. if (err) throw err;
  18. rowCount += rows.length;
  19. if (rowCount < rowsPerRun) {
  20. selectRows();
  21. return;
  22. }
  23. var duration = (Date.now() - firstSelect) / 1000;
  24. var hz = Math.round(rowCount / duration);
  25. console.log(hz);
  26. rowCount = 0;
  27. firstSelect = null;
  28. selectRows();
  29. });
  30. };