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

GenTest.d 870 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. module GenTest;
  2. import yitter.contract.IIdGenerator;
  3. import std.conv;
  4. import std.datetime;
  5. import std.stdio;
  6. class GenTest {
  7. private IIdGenerator IdGen;
  8. private int GenIdCount;
  9. private int WorkerId;
  10. this(IIdGenerator idGen, int genIdCount, int workerId) {
  11. GenIdCount = genIdCount;
  12. IdGen = idGen;
  13. WorkerId = workerId;
  14. }
  15. void GenStart() {
  16. MonoTime start = MonoTime.currTime();
  17. long id = 0;
  18. for (int i = 0; i < GenIdCount; i++) {
  19. id = IdGen.newLong();
  20. }
  21. MonoTime end = MonoTime.currTime();
  22. Duration dur = end - start;
  23. // writeln(id);
  24. writeln("++++++++++++++++++++++++++++++++++++++++WorkerId: "
  25. ~ WorkerId.to!string() ~ ", total: " ~ dur.total!("usecs").to!string() ~ " us");
  26. }
  27. }