Ejemplo n.º 1
0
 protected static void GarbageCollectRandClr(REngine engine)
 {
     GC.Collect();
     // it seems important to call gc() twice to get a proper baseline.
     engine.ForceGarbageCollection();
     engine.ForceGarbageCollection();
 }
Ejemplo n.º 2
0
 protected static void GarbageCollectRandClr(REngine engine)
 {
     // it seems needed to call gc() twice to get a proper baseline.
     REngine.DoDotNetGarbageCollection();
     engine.ForceGarbageCollection();
     REngine.DoDotNetGarbageCollection();
     engine.ForceGarbageCollection();
 }
Ejemplo n.º 3
0
        public Measurement[] DoMeasures(IDictionary <string, Action <REngine, int, Stopwatch> > funMap,
                                        string[] types = null, int[] sizes = null, string what = null, string operation = null, string tag = null, bool printToConsole = true, bool forceGC = true)
        {
            if (types == null)
            {
                types = this.Types;
            }
            if (sizes == null)
            {
                sizes = this.Sizes;
            }
            if (what == null)
            {
                what = this.What;
            }
            if (operation == null)
            {
                operation = this.Operation;
            }
            if (tag == null)
            {
                tag = this.Tag;
            }
            var measures = new List <Measurement>();

            foreach (string type in types)
            {
                for (int i = 0; i < sizes.Length; i++)
                {
                    if (forceGC)
                    {
                        engine.ForceGarbageCollection();
                    }
                    var m = MeasureRuntimeOperation(funMap[type], sizes[i], type, operation, what, tag);
                    measures.Add(m);
                    if (printToConsole)
                    {
                        Console.WriteLine(PrintRuntimeOperation(m));
                    }
                }
            }
            return(measures.ToArray());
        }
Ejemplo n.º 4
0
 private static void ReproWorkitem43(REngine engine)
 {
     Random r = new Random(0);
      int N = 500;
      int n1 = 207;
      int n2 = 623;
      var arGroup1Intensities = new double[N][];
      var arGroup2Intensities = new double[N][];
      for (int i = 0; i < N; i++)
      {
     arGroup1Intensities[i] = new double[n1];
     arGroup2Intensities[i] = new double[n2];
     for (int j = 0; j < n1; j++)
        arGroup1Intensities[i][j] = r.NextDouble();
     for (int j = 0; j < n2; j++)
        arGroup2Intensities[i][j] = r.NextDouble();
      }
      var res = new GenericVector[N];
      NumericVector vGroup1, vGroup2;
      for (int i = 0; i < N; i++)
      {
     vGroup1 = engine.CreateNumericVector(arGroup1Intensities[i]);
     Console.WriteLine(vGroup1.Length);
     if (i % 10 == 4)
     {
        engine.ForceGarbageCollection();
        engine.ForceGarbageCollection();
     }
     vGroup2 = engine.CreateNumericVector(arGroup2Intensities[i]);
     Console.WriteLine(vGroup2.Length);
     engine.SetSymbol("group1", vGroup1);
     engine.SetSymbol("group2", vGroup2);
     GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();
     res[i] = testResult;
      }
 }
Ejemplo n.º 5
0
        private static void ReproDiscussion532760(REngine engine)
        {
            // https://rdotnet.codeplex.com/discussions/532760
             //> x <- data.frame(1:1e6, row.names=format(1:1e6))
             //> object.size(x)
             //60000672 bytes
             //> object.size(rownames(x))
             //56000040 bytes

             engine.Evaluate("x <- data.frame(1:1e6, row.names=format(1:1e6))");
             var x = engine.GetSymbol("x").AsDataFrame();
             engine.ForceGarbageCollection();
             engine.ForceGarbageCollection();
             var memoryInitial = engine.Evaluate("memory.size()").AsNumeric().First();

             var netMemBefore = GC.GetTotalMemory(true);

             var blah = x.RowNames;
             //var blah = engine.Evaluate("rownames(x)").AsCharacter().ToArray();
             blah = null;

             GC.Collect();
             engine.ForceGarbageCollection();
             engine.ForceGarbageCollection();
             var memoryAfterAlloc = engine.Evaluate("memory.size()").AsNumeric().First();

             var netMemAfter = GC.GetTotalMemory(false);
        }