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.

PerfTest.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import co.wuunder.rule_engine.*;
  2. import org.junit.jupiter.api.Test;
  3. import java.util.List;
  4. import java.util.Random;
  5. import static co.wuunder.rule_engine.RateRules.*;
  6. public class PerfTest {
  7. private final RuleEngine ruleEngine = new RuleEngine(RateRules.rules(100_000));
  8. @Test
  9. public void perf() {
  10. long start = System.currentTimeMillis();
  11. int numberOfShipments = 50;
  12. for(int i = 0 ; i < numberOfShipments; i++) {
  13. ruleEngine.generateRules(shipment());
  14. }
  15. long end = System.currentTimeMillis();
  16. System.out.println((end - start) / numberOfShipments);
  17. }
  18. private Shipment randomShipment() {
  19. Random random = new Random(System.currentTimeMillis());
  20. Address pickupAddress = new Address("NL", "");
  21. Address deliveryAddress = new Address("NL", "");
  22. return new Shipment(random.nextInt(), random.nextInt(), random.nextInt(), random.nextInt(), random.nextInt() % 2 == 0, random.nextInt() % 2 == 0, pickupAddress, deliveryAddress);
  23. }
  24. private Shipment shipment() {
  25. Address pickupAddress = new Address("NL", "");
  26. Address deliveryAddress = new Address("NL", "");
  27. return new Shipment(10, 10, 10, 10, false, false, pickupAddress, deliveryAddress);
  28. }
  29. }