<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    莊周夢蝶

    生活、程序、未來
       :: 首頁 ::  ::  :: 聚合  :: 管理

    寫一個簡單的工作流(三)

    Posted on 2007-10-12 13:01 dennis 閱讀(1079) 評論(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 star
    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
    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 tech
    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
    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 set
    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
    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
    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.
    Very clean site, thanks for this post.

    # vitamind28448  回復  更多評論   

    2016-08-13 18:48 by Good post. I learn something totally new and chall
    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.

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 在线观看亚洲AV每日更新无码| fc2免费人成在线视频| 亚洲a∨国产av综合av下载| 精品国产日韩久久亚洲| 国偷自产一区二区免费视频| 亚洲电影免费在线观看| 最近免费中文字幕大全视频| 日韩在线观看视频免费| 亚洲最大中文字幕| 亚洲国产成人VA在线观看| 91福利视频免费| 特黄aa级毛片免费视频播放| 成人国产网站v片免费观看| 亚洲福利在线观看| 国产裸模视频免费区无码| 免费国产午夜高清在线视频| 亚洲精品色在线网站| 亚洲一区精品中文字幕| 亚洲AV无码乱码在线观看性色扶 | 久久精品成人免费看| 亚洲五月丁香综合视频| 亚洲色成人中文字幕网站| 无码国产精品一区二区免费| 成年免费a级毛片免费看无码| 国产91在线|亚洲| 亚洲综合最新无码专区| 亚洲精品无码mⅴ在线观看| 国产精彩免费视频| 免费一级特黄特色大片| 亚洲人成7777| 婷婷久久久亚洲欧洲日产国码AV | 亚洲不卡中文字幕无码| 国产国产成年年人免费看片| 免费看男女下面日出水来| 免费看成人AA片无码视频吃奶| 亚洲码欧美码一区二区三区| 自怕偷自怕亚洲精品| 亚洲精品国产美女久久久| 免费成人在线观看| 嫩草影院在线免费观看| 色se01短视频永久免费|