写一个简单的工作流(三) -凯发k8网页登录

生活、程序、未来
   :: 凯发k8网页登录首页 ::  ::  :: 聚合  :: 管理
posted on 2007-10-12 13:01 dennis 阅读(995) 评论(9)    
    上午测试了下并发情况下的表现,测试场景:一个有20个节点,包括选择、顺序、并行路由的流程,所有节点都设置为自动执行,1000个线程并发启动案例,也就是这个流程同时有1000个案例在跑,全部跑完结果差强人意,比单线程慢了接近30倍。仔细调整了算法和加锁粒度,尽管整体性能有所提高,但是多线程和单线程间执行的差距仍然没有多大变化,性能瓶颈还是在核心的调度算法上,还需要分析下。测试程序如下:
package net.rubyeye.insect.workflow.test;

import java.util.arraylist;
import java.util.list;
import java.util.concurrent.cyclicbarrier;

import net.rubyeye.insect.workflow.place;
import net.rubyeye.insect.workflow.token;
import net.rubyeye.insect.workflow.transition;
import net.rubyeye.insect.workflow.workflow;
import net.rubyeye.insect.workflow.workflowmanager;
import net.rubyeye.insect.workflow.basic.basicworkflowmanager;
import net.rubyeye.insect.workflow.comm.transitiontype;
import net.rubyeye.insect.workflow.config.defaultconfiguration;
import junit.framework.testcase;

public class compositeprocesstest extends testcase {
    
private workflowmanager wm;

    workflow composite;

    
private cyclicbarrier barrier;

    
private static final int total = 1000;

    @override
    
protected void setup() throws exception {
        
this.barrier = new cyclicbarrier(total  1);
        wm 
= new basicworkflowmanager();
        wm.setconfiguration(
new defaultconfiguration());

        workflow sequence 
= wm.getworkflow("sequence");
        workflow concurrency 
= wm.getworkflow("concurrency");
        workflow choose 
= wm.getworkflow("choose");

        
// 组合流程
        composite = new workflow();
        composite.setname(
"composite");
        composite.setid(
100);

        wm.saveworkflow(composite);

        
// 修改开始结束节点的输入输出库所
        sequence.getend().settype(transitiontype.normal);
        sequence.getend().setoutputs(concurrency.getstart().getinputs());

        concurrency.getend().settype(transitiontype.normal);
        concurrency.getend().setoutputs(choose.getstart().getinputs());

        composite.setstart(sequence.getstart());
        composite.setend(choose.getend());
        list
<transition> transitions = new arraylist<transition>();
        transitions.addall(sequence.gettransitions());
        transitions.addall(concurrency.gettransitions());
        transitions.addall(choose.gettransitions());
        composite.settransitions(transitions);
    }

    
public void testconcurrencycompositeprocesss() throws exception {
        
for (int i = 0; i < total; i) {
            
new flowthread().start();
        }
        barrier.await();
        
long start = system.currenttimemillis();
        barrier.await();
        
long end = system.currenttimemillis();
        system.out.println(
"创建"  total  "个流程并发运行完毕\n花费时间:"  (end - start)
                
/ 1000.0  "");
        
for (transition transition : composite.gettransitions()) {
            system.out.println(transition.getname() 
 "  "
                    
 transition.isenable());
            
for (place place : transition.getoutputs()) {
                system.out.println(
"place "  place.getid()  " "
                        
 place.gettokens().size());
            }
        }
    }

    
public void testcompositeprocesss() throws exception {
        
long start = system.currenttimemillis();
        
for (int i = 0; i < total; i) {
            token token1 
= wm.startworkflow("composite");
            token1.setattribute(
"name""dennis");
            token1.setattribute(
"num"21);
            wm.doaction(token1.getid());
            asserttrue(token1.isfinished());
        }
        
long end = system.currenttimemillis();
        system.out.println(
"创建"  total  "个流程运行完毕\n花费时间:"  (end - start)
                
/ 1000.0  "");
    }

    
class flowthread extends thread {

        @override
        
public void run() {
            
try {
                barrier.await();
                
// wm = new basicworkflowmanager();
                token token1 = wm.startworkflow("composite");
                token1.setattribute(
"name""dennis");
                token1.setattribute(
"num"21);
                wm.doaction(token1.getid());
                asserttrue(token1.isfinished());
                barrier.await();
            } 
catch (exception e) {
                
throw new runtimeexception(e);
            }
        }

    }
}


评论

# fatdiminishersystem91202  回复     

2015-10-30 21:08 by
i know this if off topic but i'm looking into starting my own weblog and was curious what all is needed to get set up? i'm assuming having a blog like yours would cost a pretty penny? i'm not very internet smart so i'm not 100% certain. any suggestions or advice would be greatly appreciated. many thanks

# numériservoscassettes39866  回复     

2015-11-01 10:21 by
i want to to thank you for this very good read!! i absolutely loved every bit of it. i have you book-marked to check out new things you post…

# loansforpeoplewithbadcredit71577  回复     

2015-11-02 03:02 by
if some one desires to be updated with latest technologies afterward he must be visit this website and be up to date all the time.

# skisafari2triche85524  回复     

2015-11-04 08:15 by
you ought to take part in a contest for one of the finest websites on the web. i'm going to recommend this website!

# clashofclanshack804  回复     

2015-11-19 10:34 by
you need to learn about the content and safety settings of your game systems. the picture to the right is of one of the many rites you can earn in the game. try to keep your stash of wood as low as possible to minimize the wood losses during attacks.

# clashofclanshack20181  回复     

2015-11-19 21:18 by
if you wish to give a game a try, the library may have a copy. make sure to take breaks between quests, races and fights. give a warning, first and maybe even start a new activity.

# japanesegirlsmovie19025  回复     

2016-04-06 20:23 by
its like you read my mind! you seem to know a lot about this, like you wrote the book in it or something. i think that you could do with a few pics to drive the message home a little bit, but other than that, this is great blog. a fantastic read. i will definitely be back.

# clashofclanshack1155  回复     

2016-06-14 22:17 by
very clean site, thanks for this post.

# vitamind28448  回复     

2016-08-13 18:48 by
good post. i learn something totally new and challenging on sites i stumbleupon on a daily basis. it will always be helpful to read content from other writers and practice something from their web sites.

只有注册用户后才能发表评论。


网站导航:
              
 
网站地图