当前位置: 首页>>代码示例>>C#>>正文


C# Rete.clearAll方法代码示例

本文整理汇总了C#中Creshendo.Util.Rete.Rete.clearAll方法的典型用法代码示例。如果您正苦于以下问题:C# Rete.clearAll方法的具体用法?C# Rete.clearAll怎么用?C# Rete.clearAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Creshendo.Util.Rete.Rete的用法示例。


在下文中一共展示了Rete.clearAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainTest


//.........这里部分代码省略.........
            Console.WriteLine("loading file " + rulefile);
            Console.WriteLine("Used memory before creating objects " + total1 + " bytes " +
                              (total1/1024) + " Kb");
            for (int idx = 0; idx < count; idx++)
            {
                Account acc = new Account();
                acc.AccountId = "acc" + idx;
                // acc.setAccountId("acc" + ran.Next(4));
                acc.AccountType = "standard";
                acc.First = Convert.ToString(ran.Next(100000));
                acc.Last = Convert.ToString(ran.Next(100000));
                acc.Middle = Convert.ToString(ran.Next(100000));
                acc.OfficeCode = Convert.ToString(ran.Next(100000));
                acc.RegionCode = Convert.ToString(ran.Next(100000));
                acc.Status = "active";
                acc.Title = "mr";
                acc.Username = Convert.ToString(ran.Next(100000));
                acc.AreaCode = Convert.ToString(ran.Next(999));
                acc.Exchange = Convert.ToString(ran.Next(999));
                acc.Number = Convert.ToString(ran.Next(999));
                acc.Ext = Convert.ToString(ran.Next(9999));
                objects.Add(acc);
            }
            long total2 = GC.GetTotalMemory(true);
            //long free2 = rt.freeMemory();
            //long used2 = total2 - free2;
            Console.WriteLine("Used memory after creating objects " + total2 + " bytes " +
                              (total2/1024) + " Kb " + (total2/1024/1024) + " Mb");
            int loop = 5;
            long ETTotal = 0;
            for (int idx = 0; idx < loop; idx++)
            {
                Rete engine = new Rete();
                engine.declareObject(typeof (Account), "Account");

                try
                {
                    StreamReader freader = new StreamReader(rulefile);
                    CLIPSParser parser = new CLIPSParser(engine, freader);
                    //Object item = null;
                    ArrayList list = new ArrayList();
                    long start = DateTime.Now.Ticks;
                    parse(engine, parser, list);
                    long end = DateTime.Now.Ticks;
                    long el = end - start;
                    // parser.close();
                    //rt.gc();
                    Console.WriteLine("time to parse rules " + el + " ms");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                IEnumerator itr = objects.GetEnumerator();
                long start2 = DateTime.Now.Ticks;
                try
                {
                    while (itr.MoveNext())
                    {
                        engine.assertObject(itr.Current, "Account", false, false);
                    }
                }
                catch (AssertException e)
                {
                    Console.WriteLine(e.Message);
                }
                long end2 = DateTime.Now.Ticks;
                long start3 = DateTime.Now.Ticks;
                int fired = 0;
                try
                {
                    fired = engine.fire();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                long end3 = DateTime.Now.Ticks;
                long total3 = GC.GetTotalMemory(true);
                //long free3 = rt.freeMemory();
                //long used3 = total3 - free3;
                Console.WriteLine("Number of rules: " +
                                  engine.CurrentFocus.RuleCount);
                Console.WriteLine("rules fired " + fired);
                Console.WriteLine("Used memory after asserting objects " + total3 + " bytes " +
                                  (total3/1024) + " Kb " + (total3/1024/1024) + " Mb");
                Console.WriteLine("number of facts " + engine.ObjectCount);
                Console.WriteLine("memory used by facts " + (total3 - total3)/1024/1024 + " Mb");
                Console.WriteLine("elapsed time to assert " + (end2 - start2) + " ms");
                Console.WriteLine("elapsed time to fire " + (end3 - start3) + " ms");
                ETTotal += (end2 - start2);
                engine.printWorkingMemory(true, false);
                //engine.close();
                engine.clearAll();
                engine.close();
                //rt.gc();
            }
            Console.WriteLine("Average ET to assert " + (ETTotal/loop) + " ms");
        }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: testRetractNoShadow

 public void testRetractNoShadow()
 {
     Console.WriteLine("testRetractNoShadow");
     Random ran = new Random();
     ArrayList objects = new ArrayList();
     // Runtime rt = Runtime.getRuntime();
     long total1 = GC.GetTotalMemory(true);
     //long free1 = rt.freeMemory();
     //long used1 = total1 - free1;
     int count = 50000;
     Console.WriteLine("Used memory before creating objects " + total1 + " bytes " +
                       (total1/1024) + " Kb");
     for (int idx = 0; idx < count; idx++)
     {
         Account acc = new Account();
         acc.AccountId = Convert.ToString(ran.Next(100000));
         acc.AccountType = Convert.ToString(ran.Next(100000));
         acc.First = Convert.ToString(ran.Next(100000));
         acc.Last = Convert.ToString(ran.Next(100000));
         acc.Middle = Convert.ToString(ran.Next(100000));
         acc.OfficeCode = Convert.ToString(ran.Next(100000));
         acc.RegionCode = Convert.ToString(ran.Next(100000));
         acc.Status = Convert.ToString(ran.Next(100000));
         acc.Title = Convert.ToString(ran.Next(100000));
         acc.Username = Convert.ToString(ran.Next(100000));
         acc.AreaCode = Convert.ToString(ran.Next(999));
         acc.Exchange = Convert.ToString(ran.Next(999));
         acc.Number = Convert.ToString(ran.Next(999));
         acc.Ext = Convert.ToString(ran.Next(9999));
         objects.Add(acc);
     }
     long total2 = GC.GetTotalMemory(true);
     //long free2 = rt.freeMemory();
     //long used2 = total2 - free2;
     Console.WriteLine("Used memory after creating objects " + total2 + " bytes " +
                       (total2/1024) + " Kb " + (total2/1024/1024) + " Mb");
     Rete engine = new Rete();
     engine.declareObject(typeof (Account));
     IEnumerator itr = objects.GetEnumerator();
     long start = DateTime.Now.Ticks;
     try
     {
         while (itr.MoveNext())
         {
             engine.assertObject(itr.Current, null, false, false);
         }
     }
     catch (AssertException e)
     {
         Console.WriteLine(e.Message);
     }
     long end = DateTime.Now.Ticks;
     long assertET = end - start;
     long total3 = GC.GetTotalMemory(true);
     //long free3 = rt.freeMemory();
     //long used3 = total3 - free3;
     //rt.gc();
     Console.WriteLine("Used memory after asserting objects " + total3 + " bytes " +
                       (total3/1024) + " Kb " + (total3/1024/1024) + " Mb");
     Console.WriteLine("number of facts " + engine.ObjectCount);
     Console.WriteLine("memory used by facts " + (total3 - total3)/1024/1024 + " Mb");
     Console.WriteLine("elapsed time is assert " + assertET + " ms");
     // now retract
     IEnumerator itr2 = objects.GetEnumerator();
     long retstart = DateTime.Now.Ticks;
     try
     {
         while (itr2.MoveNext())
         {
             engine.retractObject(itr2.Current);
         }
     }
     catch (RetractException e)
     {
         Console.WriteLine(e.Message);
     }
     long retend = DateTime.Now.Ticks;
     long retractET = retend - retstart;
     long total4 = GC.GetTotalMemory(true);
     //long free4 = rt.freeMemory();
     //long used4 = total4 - free4;
     objects.Clear();
     engine.clearAll();
     engine.close();
     //rt.gc();
     Console.WriteLine("elapsed time to retract " + retractET + " ms");
     // the retract should be atleast 3 times shorter than the assert
     #if DEBUG
     Assert.IsTrue(retractET > 0);
     #else
     Assert.IsTrue((assertET > (retractET*3)));
     #endif
 }
开发者ID:,项目名称:,代码行数:93,代码来源:

示例3: executeFunction

 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     DefaultReturnVector ret = new DefaultReturnVector();
     if (params_Renamed != null && params_Renamed.Length == 1)
     {
         if (params_Renamed[0].StringValue.Equals("objects"))
         {
             engine.clearObjects();
         }
         else if (params_Renamed[0].StringValue.Equals("deffacts"))
         {
             engine.clearFacts();
         }
     }
     else
     {
         engine.clearAll();
     }
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, true);
     ret.addReturnValue(rv);
     return ret;
 }
开发者ID:,项目名称:,代码行数:22,代码来源:


注:本文中的Creshendo.Util.Rete.Rete.clearAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。