internal Runner(int index, int countThreshold, int maxArrays, ExecutorService pool , int p, ByteArrayManager bam) { this.maxArrayLength = Index2arrayLength(index); this.countThreshold = countThreshold; this.maxArrays = maxArrays; this.pool = pool; this.p = p; this.bam = bam; }
/// <exception cref="System.Exception"/> public static void Main(string[] args) { ((Log4JLogger)LogFactory.GetLog(typeof(ByteArrayManager))).GetLogger().SetLevel(Level .Off); int arrayLength = 64 * 1024; //64k int nThreads = 512; int nAllocations = 1 << 15; int maxArrays = 1 << 10; int nTrials = 5; System.Console.Out.WriteLine("arrayLength=" + arrayLength + ", nThreads=" + nThreads + ", nAllocations=" + nAllocations + ", maxArrays=" + maxArrays); Random ran = DFSUtil.GetRandom(); ByteArrayManager[] impls = new ByteArrayManager[] { new ByteArrayManager.NewByteArrayWithoutLimit (), new TestByteArrayManager.NewByteArrayWithLimit(maxArrays), new ByteArrayManager.Impl (new ByteArrayManager.Conf(DFSConfigKeys.DfsClientWriteByteArrayManagerCountThresholdDefault , maxArrays, DFSConfigKeys.DfsClientWriteByteArrayManagerCountResetTimePeriodMsDefault )) }; double[] avg = new double[impls.Length]; for (int i = 0; i < impls.Length; i++) { double duration = 0; Printf("%26s:", impls[i].GetType().Name); for (int j = 0; j < nTrials; j++) { int[] sleepTime = new int[nAllocations]; for (int k = 0; k < sleepTime.Length; k++) { sleepTime[k] = ran.Next(100); } long elapsed = PerformanceTest(arrayLength, maxArrays, nThreads, sleepTime, impls [i]); duration += elapsed; Printf("%5d, ", elapsed); } avg[i] = duration / nTrials; Printf("avg=%6.3fs", avg[i] / 1000); for (int j_1 = 0; j_1 < i; j_1++) { Printf(" (%6.2f%%)", PercentageDiff(avg[j_1], avg[i])); } Printf("\n"); } }
/// <exception cref="System.Exception"/> internal static long PerformanceTest(int arrayLength, int maxArrays, int nThreads , int[] sleepTimeMSs, ByteArrayManager impl) { ExecutorService pool = Executors.NewFixedThreadPool(nThreads); IList <Future <Void> > futures = new AList <Future <Void> >(sleepTimeMSs.Length); long startTime = Time.MonotonicNow(); for (int i = 0; i < sleepTimeMSs.Length; i++) { long sleepTime = sleepTimeMSs[i]; futures.AddItem(pool.Submit(new _Callable_628(impl, arrayLength, sleepTime))); } foreach (Future <Void> f in futures) { f.Get(); } long endTime = Time.MonotonicNow(); pool.Shutdown(); return(endTime - startTime); }
public _Callable_628(ByteArrayManager impl, int arrayLength, long sleepTime) { this.impl = impl; this.arrayLength = arrayLength; this.sleepTime = sleepTime; }
internal Recycler(ByteArrayManager bam) { this.bam = bam; }
internal Allocator(ByteArrayManager bam) { this.bam = bam; }
internal AllocatorThread(int arrayLength, ByteArrayManager bam) { this.bam = bam; this.arrayLength = arrayLength; }