/usr/share/psychtoolbox-3/PsychTests/JavaClockTest.m is in psychtoolbox-3-common 3.0.11.20140816.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | function timeDiffs=JavaClockTest(testDurationMinutes)
% JavaClockTest
%
% Test for divergence between the java.lang.System.currentTimeMillis() and
% GetSecs clocks.
%
% see also: CalibrateJavaClock, JavaTimeToGetSecs, GetChar
% HISTORY
%
% 6/7/06 awi Wrote it.
% 6/15/06 awi Modified for new JavaTimeToGetSecs which does not cache
% clock difference.
if nargin<1
testDurationMinutes=3;
end
testIntervalMinutes = 1;
samplesPerTest= 100;
fprintf(['TestJavaClock will sample clocks at ' num2str(testIntervalMinutes) '-minute intervals for ' num2str(testDurationMinutes) ' minutes.\n' ]);
validKeyFlag=0;
while ~validKeyFlag
fprintf('Proceed with test? [y/n]: ');
c=GetChar;
fprintf([' ' c '\n']);
proceedFlag=strcmp(upper(c), 'Y');
exitFlag=strcmp(upper(c), 'N');
validKeyFlag= exitFlag || proceedFlag;
if ~validKeyFlag
fprintf('Unrecognized response.\n');
end
end
if exitFlag
fprintf('Exiting TestJavaClock function without running test.\n');
return;
end
GetSecs;
java.lang.System.currentTimeMillis();
testTimesMinutes=linspace(0, testDurationMinutes, testDurationMinutes/testIntervalMinutes + 1);
testTimesSecsAbsolute= GetSecs + testTimesMinutes * 60 + 1; %wait five seconds before first test.
numTests=length(testTimesMinutes);
i=1;
t1Secs=zeros(1,samplesPerTest);
t2Secs=zeros(1,samplesPerTest);
while i<= numTests
while GetSecs < testTimesSecsAbsolute(i);
WaitSecs(testTimesSecsAbsolute(i) - GetSecs);
end
fprintf(['Starting time sample loop ' int2str(i) ' of ' int2str(numTests) ' at ' datestr(now) '\n']);
oldPriority=Priority;
try
Priority(9);
for s=1:samplesPerTest
t1Secs(s)=GetSecs;
t2Secs(s)=java.lang.System.currentTimeMillis() / 1000.0;
end
Priority(oldPriority);
catch
Priority(oldPriority);
end
meanDiffs(i)=mean(abs(t2Secs-t1Secs));
i=i+1;
end
timeDiffs=meanDiffs-meanDiffs(1);
fprintf('Plotting difference between clocks...');
plot(testTimesMinutes, timeDiffs, 'rx-');
xlabel('Time in Minutes');
ylabel('Java clock - GetSecs');
fprintf(' done.\n');
|