/** * Does the testing. Steps: * * <ul> * <li>starts the Shifter thread * <li>during the given time starts new Worker threads, keeping the number of live thread under * limit. * <li>stops the Shifter thread * </ul> * * @param timeInMillis how long to stress * @param maxThreads the maximum number of Worker thread working together. */ public void test(long timeInMillis, int maxThreads) { if (timeInMillis <= 0 || maxThreads <= 0) { throw new IllegalArgumentException("TEST BUG: be positive!"); } System.out.println("%% Time to work: " + timeInMillis / 1000 + "s"); System.out.println("%% Number of threads: " + maxThreads); long finish = System.currentTimeMillis() + timeInMillis; Shifter shift = new Shifter(this, 1000, (int) (windowSize * 0.9)); shift.start(); for (int i = 0; i < maxThreads; i++) { new Worker(this, 100).start(); } try { while (System.currentTimeMillis() < finish && errorMessage == null) { Thread.sleep(100); } } catch (Throwable t) { printAllStackTraces(System.err); t.printStackTrace(System.err); this.errorMessage = t.getMessage(); } finally { isEnough = true; } System.out.println("%% Total work cycles: " + counter); if (errorMessage != null) { throw new RuntimeException(errorMessage); } }
public void robotInit() { // instantiate the command used for the autonomous period autonomousCommand = new AutonomousCommand(); // Initialize all subsystems // VisionProcessing.getInstance(); Drivetrain.getInstance(); OI.getInstance(); Shifter.getInstance(); IntakeMotor.getInstance(); IntakePiston.getInstance(); Catapult.getInstance(); }
/** Returns the value of this sub-node. */ public short get() { return Shifter.unsignedShiftRight((short) (value & mask), shiftRight); }