File: macspeedtest.inc

package info (click to toggle)
castle-game-engine 6.4%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 195,044 kB
  • sloc: pascal: 364,622; ansic: 8,606; java: 2,851; objc: 2,601; cpp: 1,412; xml: 851; makefile: 723; sh: 563; php: 26
file content (46 lines) | stat: -rw-r--r-- 1,862 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ Parametry SpeedTest_Name, SpeedTest_FasterName, SpeedTest_SlowerName (string)
            SpeedTest_Cycles (Cardinal)
            SpeedTest_DoFasterCycle (Pascal instruction, without ; at the end)
            SpeedTest_DoSlowerCycle (Pascal instruction, without ; at the end)
  SpeedTest_DoFasterCycle nie musi w rzeczywistosci byc szybsze od
  SpeedTest_DoSlowerCycle, po prostu jezeli zdarzy sie ze jest bardziej wolne
  to bedzie wypisany smieszny (ale w gruncie rzeczy sensowny) komunikat
  w rodzaju
    'Faster is faster than Slower by 0.5'
  (tzn. jest szybsze pol raza, czyli de facto 2 razy bardziej wolne).
}

{$define SpeedTest_Declare:=
  {$ifndef NO_SPEED_TESTS}
  var
    SpeedTest_i: Cardinal;
    SpeedTest_Time0, SpeedTest_Time1, SpeedTest_Time2: Double;
    StartTime: TProcessTimerResult;
  {$endif not NO_SPEED_TESTS}
}

{$define SpeedTest:=
  {$ifndef NO_SPEED_TESTS}
  Writeln('SPEED TEST ',SpeedTest_Name, '-------------------');

  StartTime := ProcessTimer;
  for SpeedTest_i := 1 to SpeedTest_Cycles do ;
  SpeedTest_Time0 := ProcessTimerSeconds(ProcessTimer, StartTime);
  Writeln(Format('Empty loop = %f',[SpeedTest_Time0]));

  StartTime := ProcessTimer;
  for SpeedTest_i := 1 to SpeedTest_Cycles do SpeedTest_DoFasterCycle;
  SpeedTest_Time1 := ProcessTimerSeconds(ProcessTimer, StartTime);
  Writeln(SpeedTest_FasterName, Format(' = %f',[SpeedTest_Time1]));

  StartTime := ProcessTimer;
  for SpeedTest_i := 1 to SpeedTest_Cycles do SpeedTest_DoSlowerCycle;
  SpeedTest_Time2 := ProcessTimerSeconds(ProcessTimer, StartTime);
  Writeln(SpeedTest_SlowerName, Format(' = %f',[SpeedTest_Time2]));

  Writeln(SpeedTest_FasterName, ' is faster than ',
          SpeedTest_SlowerName, ' by ',
	   Format('%f', [(SpeedTest_Time2-SpeedTest_Time0)/
	                 (SpeedTest_Time1-SpeedTest_Time0)]));
  {$endif not NO_SPEED_TESTS}
}