コード例 #1
0
 /// <summary> 
 /// 
 /// </summary>
 public virtual void testTwoSharedNodes()
 {
     try
     {
         int factCount = 5000;
         string file = "20rules_2CE_2shared.drl";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         System.Diagnostics.Process rt = System.Diagnostics.Process.GetCurrentProcess();
         for (int c = 0; c < loop; c++)
         {
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = readRule(file);
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long loadet = loadEnd - loadStart;
             totalload += loadet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             Account acc = new Account();
             acc.Status = "standard";
             objects.Add(acc);
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Address addr = new Address();
                 addr.City = "boston";
                 addr.State = "ma";
                 addr.HouseType = "single family" + idx;
                 addr.Status = "not listed";
                 addr.Country = "usa";
                 objects.Add(addr);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
             while (itr.MoveNext())
             {
                 //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
             System.GC.Collect();
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
     //				SupportClass.WriteStackTrace(e, Console.Error);
     }
 }
コード例 #2
0
 /// <summary> test the performance with 50 facts and 5 rules. The test measures
 /// the load, assert and fire time.
 /// </summary>
 public virtual void testFiveSharedNodes()
 {
     try
     {
         int factCount = 5000;
         string file = "20rules_2CE_5shared.drl";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         long aveloadmem = 0;
         long aveassertmem = 0;
         System.Diagnostics.Process rt = System.Diagnostics.Process.GetCurrentProcess();
         for (int c = 0; c < loop; c++)
         {
             System.GC.Collect();
             //long memt1 = rt.totalMemory();
             //long memf1 = rt.freeMemory();
             //long used1 = memt1 - memf1;
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = readRule(file);
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //long memt2 = rt.totalMemory();
             //long memf2 = rt.freeMemory();
             //long used2 = memt2 - memf2;
             long loadet = loadEnd - loadStart;
             System.GC.Collect();
             totalload += loadet;
             //aveloadmem += (used2 - used1);
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             //System.Console.Out.WriteLine("load memory used " + ((used2 - used1) / 1024) + " kb");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             Account acc = new Account();
             acc.Status = "standard";
             objects.Add(acc);
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Address addr = new Address();
                 addr.City = "boston";
                 addr.State = "ma";
                 addr.HouseType = "single family";
                 addr.Status = "not listed";
                 addr.Country = "usa";
                 addr.AccountId = "acc" + idx;
                 objects.Add(addr);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             //long memt3 = rt.totalMemory();
             //long memf3 = rt.freeMemory();
             //long used3 = memt3 - memf3;
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             while (itr.MoveNext())
             {
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //long memt4 = rt.totalMemory();
             //long memf4 = rt.freeMemory();
             //long used4 = memt4 - memf4;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             //aveassertmem += (used4 - used3);
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             //System.Console.Out.WriteLine("assert memory used " + ((used4 - used3) / 1024) + " kb");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
             System.GC.Collect();
             System.Console.Out.WriteLine("");
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         //System.Console.Out.WriteLine("average load mem " + (aveloadmem / 1024 / loop) + " kb");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         //System.Console.Out.WriteLine("average assert mem " + (aveassertmem / 1024 / loop) + " kb");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
     //				SupportClass.WriteStackTrace(e, Console.Error);
     }
 }
コード例 #3
0
 /// <summary> 
 /// 
 /// </summary>
 public void testTwoSharedNodes()
 {
     try
     {
         int factCount = 5000;
         string file = "20rules_2shared.drl";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         System.Diagnostics.Process rt = System.Diagnostics.Process.GetCurrentProcess();
         for (int c = 0; c < loop; c++)
         {
             System.GC.Collect();
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = readRule(file);
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long loadet = loadEnd - loadStart;
             totalload += loadet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Address addr = new Address();
                 addr.City = "boston";
                 addr.State = "ma";
                 addr.HouseType = "single family" + idx;
                 addr.Status = "not listed";
                 addr.Country = "usa";
                 objects.Add(addr);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             while (itr.MoveNext())
             {
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
             System.GC.Collect();
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
         //SupportClass.WriteStackTrace(e, Console.Error);
     }
 }