@Test public void testMachineRunPerf() throws InterruptedException { final int count = 500; int threadCount = 5; long startTime = System.currentTimeMillis(); Thread[] threadList = new Thread[threadCount]; for (int i = 0; i < threadCount; i++) { threadList[i] = new Thread("perf-thread-" + i) { @Override public void run() { for (int i = 0; i < count; i++) { String bizId = getBizId(); PersistMachine m = persistMachineFactory.newInstance(bizId, "process"); m.addContext("goto", 2); m.addContext("_i", 3); m.run(); System.out.println("thread:" + this.getName() + " count:" + i + " bizId:" + bizId); } } }; } for (Thread t : threadList) { t.start(); } for (Thread t : threadList) { t.join(); } long duration = System.currentTimeMillis() - startTime; System.out.println("total time:" + duration + "ms"); System.out.println("average time:" + (duration / (count * threadCount)) + "ms"); }
public String getBizId() { return bizId; }
PersistMachine extends Machine { public String getBizId() { return bizId; } }
PersistMachine extends Machine { public String getBizId() { return bizId; } protected  PersistMachine(String bizId, String processName, int processVersion, ProcessDO processDO,
                             ProcessDOMapper processDOMapper
        , StateDOMapper stateDOMapper
        , PersistHelper persistHelper
        , TaskDOMapper taskDOMapper
        , ParticipationDOMapper participationDOMapper
        , JobDOMapper jobDOMapper); }
PersistMachine extends Machine { public String getBizId() { return bizId; } protected  PersistMachine(String bizId, String processName, int processVersion, ProcessDO processDO,
                             ProcessDOMapper processDOMapper
        , StateDOMapper stateDOMapper
        , PersistHelper persistHelper
        , TaskDOMapper taskDOMapper
        , ParticipationDOMapper participationDOMapper
        , JobDOMapper jobDOMapper); List<StateDOWithBLOBs> getStateDOList(); String getStatePathString(); void rollback(); String getBizId(); boolean isExist(); boolean isCompleted(); ProcessDO getProcessDO(); }
PersistMachine extends Machine { public String getBizId() { return bizId; } protected  PersistMachine(String bizId, String processName, int processVersion, ProcessDO processDO,
                             ProcessDOMapper processDOMapper
        , StateDOMapper stateDOMapper
        , PersistHelper persistHelper
        , TaskDOMapper taskDOMapper
        , ParticipationDOMapper participationDOMapper
        , JobDOMapper jobDOMapper); List<StateDOWithBLOBs> getStateDOList(); String getStatePathString(); void rollback(); String getBizId(); boolean isExist(); boolean isCompleted(); ProcessDO getProcessDO();  }