Beispiel #1
0
 public virtual void AdjustDelays(Delays delays)
 {
     for (int i = 0; i < Delays.Count; i++)
     {
         AdjustDelay(delays, i);
     }
 }
Beispiel #2
0
		public virtual void AdjustDelays(Delays delays)
		{
			for (int i = 0; i < Delays.Count; i++)
			{
				AdjustDelay(delays, i);
			}
		}
Beispiel #3
0
        /// <exception cref="NumberFormatException"></exception>
        /// <exception cref="IOException"></exception>
        private void ParseLog()
        {
            StreamReader reader    = new StreamReader(_logFileName);
            long         readTime  = 0;
            long         writeTime = 0;
            long         syncTime  = 0;
            string       line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.StartsWith(LogConstants.ReadEntry))
                {
                    readTime = ExtractNumber(line);
                }
                else
                {
                    if (line.StartsWith(LogConstants.WriteEntry))
                    {
                        writeTime = ExtractNumber(line);
                    }
                    else if (line.StartsWith(LogConstants.SyncEntry))
                    {
                        syncTime = ExtractNumber(line);
                    }
                }
            }
            reader.Close();
            times = new Delays(readTime, writeTime, syncTime);
        }
Beispiel #4
0
        private void AdjustDelay(Delays delays, int index)
        {
            TicksStopWatch watch  = new TicksStopWatch();
            TicksTiming    timing = new TicksTiming();
            long           difference;
            long           differencePerIteration;
            long           average        = 0;
            long           oldAverage     = 0;
            long           delay          = delays.values[index];
            long           adjustedDelay  = delay;
            int            adjustmentRuns = 1;
            long           targetRuntime  = AdjustmentIterations * delay;
            long           minimumDelay   = MinimumDelay();

            WarmUpIterations(delay, timing);
            do
            {
                watch.Start();
                for (int i = 0; i < AdjustmentIterations; i++)
                {
                    timing.WaitTicks(adjustedDelay);
                }
                watch.Stop();
                difference             = targetRuntime - watch.Elapsed();
                differencePerIteration = difference / AdjustmentIterations;
                if (-differencePerIteration > adjustedDelay)
                {
                    adjustedDelay /= 2;
                }
                else
                {
                    adjustedDelay += differencePerIteration;
                    oldAverage     = average;
                    if (adjustmentRuns == 1)
                    {
                        average = adjustedDelay;
                    }
                    else
                    {
                        average = ((average * (adjustmentRuns - 1)) / adjustmentRuns) + (adjustedDelay /
                                                                                         adjustmentRuns);
                    }
                    adjustmentRuns++;
                }
                if (adjustedDelay <= 0)
                {
                    break;
                }
                if ((Math.Abs(average - oldAverage) < (0.01 * delay)) && adjustmentRuns > 10)
                {
                    break;
                }
            }while (true);
            if (average < minimumDelay)
            {
                Sharpen.Runtime.Err.WriteLine(">> Smallest achievable delay: " + minimumDelay);
                Sharpen.Runtime.Err.WriteLine(">> Required delay setting: " + average);
                Sharpen.Runtime.Err.WriteLine(">> Using delay(0) to wait as short as possible.");
                Sharpen.Runtime.Err.WriteLine(">> Results will not be accurate.");
                average = 0;
            }
            delays.values[index] = average;
        }
Beispiel #5
0
		/// <exception cref="NumberFormatException"></exception>
		private void ProcessResultsFiles(string resultsFile1, string resultsFile2)
		{
			Sysout("Delaying:");
			try
			{
				DelayCalculation calculation = new DelayCalculation(resultsFile1, resultsFile2);
				calculation.ValidateData();
				if (!calculation.IsValidData())
				{
					ExitWithError("> Result files are invalid for delaying!");
				}
				_delays = calculation.CalculatedDelays();
				Sysout("> Required delays:");
				Sysout("> " + _delays);
				Sysout("> Adjusting delay timer to match required delays...");
				calculation.AdjustDelays(_delays);
				Sysout("> Adjusted delays:");
				Sysout("> " + _delays);
			}
			catch (IOException)
			{
				ExitWithError("> Could not open results file(s)!\n" + "> Please check the file name settings in IoBenchmark.properties."
					);
			}
		}
Beispiel #6
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public DelayingBin(IBin bin, Delays delays) : base(bin)
 {
     _delays = delays;
     _timing = new TicksTiming();
 }
Beispiel #7
0
 public DelayingStorage(IStorage delegateAdapter, Delays delays) : base(delegateAdapter
                                                                        )
 {
     _delays = delays;
 }
Beispiel #8
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
                          initialLength, Delays delays) : this(delegateAdapter.Open(path, lockFile, initialLength
                                                                                    , false), delays)
 {
 }
Beispiel #9
0
 public DelayingIoAdapter(IoAdapter delegateAdapter, Delays delays) : base(delegateAdapter
                                                                           )
 {
     _delays = delays;
     _timing = new TicksTiming();
 }
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
			 initialLength, Delays delays) : this(delegateAdapter.Open(path, lockFile, initialLength
			, false), delays)
		{
		}
		public DelayingIoAdapter(IoAdapter delegateAdapter, Delays delays) : base(delegateAdapter
			)
		{
			_delays = delays;
			_timing = new TicksTiming();
		}
Beispiel #12
0
		private void AdjustDelay(Delays delays, int index)
		{
			TicksStopWatch watch = new TicksStopWatch();
			TicksTiming timing = new TicksTiming();
			long difference;
			long differencePerIteration;
			long average = 0;
			long oldAverage = 0;
			long delay = delays.values[index];
			long adjustedDelay = delay;
			int adjustmentRuns = 1;
			long targetRuntime = AdjustmentIterations * delay;
			long minimumDelay = MinimumDelay();
			WarmUpIterations(delay, timing);
			do
			{
				watch.Start();
				for (int i = 0; i < AdjustmentIterations; i++)
				{
					timing.WaitTicks(adjustedDelay);
				}
				watch.Stop();
				difference = targetRuntime - watch.Elapsed();
				differencePerIteration = difference / AdjustmentIterations;
				if (-differencePerIteration > adjustedDelay)
				{
					adjustedDelay /= 2;
				}
				else
				{
					adjustedDelay += differencePerIteration;
					oldAverage = average;
					if (adjustmentRuns == 1)
					{
						average = adjustedDelay;
					}
					else
					{
						average = ((average * (adjustmentRuns - 1)) / adjustmentRuns) + (adjustedDelay / 
							adjustmentRuns);
					}
					adjustmentRuns++;
				}
				if (adjustedDelay <= 0)
				{
					break;
				}
				if ((Math.Abs(average - oldAverage) < (0.01 * delay)) && adjustmentRuns > 10)
				{
					break;
				}
			}
			while (true);
			if (average < minimumDelay)
			{
				Sharpen.Runtime.Err.WriteLine(">> Smallest achievable delay: " + minimumDelay);
				Sharpen.Runtime.Err.WriteLine(">> Required delay setting: " + average);
				Sharpen.Runtime.Err.WriteLine(">> Using delay(0) to wait as short as possible.");
				Sharpen.Runtime.Err.WriteLine(">> Results will not be accurate.");
				average = 0;
			}
			delays.values[index] = average;
		}
Beispiel #13
0
		/// <exception cref="NumberFormatException"></exception>
		/// <exception cref="IOException"></exception>
		private void ParseLog()
		{
			StreamReader reader = new StreamReader(_logFileName);
			long readTime = 0;
			long writeTime = 0;
			long seekTime = 0;
			long syncTime = 0;
			string line = null;
			while ((line = reader.ReadLine()) != null)
			{
				if (line.StartsWith(LogConstants.ReadEntry))
				{
					readTime = ExtractNumber(line);
				}
				else
				{
					if (line.StartsWith(LogConstants.WriteEntry))
					{
						writeTime = ExtractNumber(line);
					}
					else
					{
						if (line.StartsWith(LogConstants.SeekEntry))
						{
							seekTime = ExtractNumber(line);
						}
						else
						{
							if (line.StartsWith(LogConstants.SyncEntry))
							{
								syncTime = ExtractNumber(line);
							}
						}
					}
				}
			}
			reader.Close();
			times = new Delays(readTime, writeTime, seekTime, syncTime);
		}
Beispiel #14
0
			/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
			public DelayingBin(IBin bin, Delays delays) : base(bin)
			{
				_delays = delays;
				_timing = new TicksTiming();
			}
Beispiel #15
0
		public DelayingStorage(IStorage delegateAdapter, Delays delays) : base(delegateAdapter
			)
		{
			_delays = delays;
		}