@Test public void testSetGoldTime() { Timing timer = new Timing(); long gold = 10; timer.setGoldTime(gold); assertEquals(timer.goldTime, 10); }
@Test public void testGetCurrentRunTime() { Timing timer = new Timing(); timer.setStartTime(); timer.getCurrentRunTime(); assertNotEquals(timer.getCurrentRunTime(), 0); }
public void Add_timing(int start, int finish, int Quantity, Context context) { Timing new_Timing = new Timing(); new_Timing.Time_Hour = start; new_Timing.Time_Min = finish; new_Timing.Med_quantity = Quantity; TimingsHandler handler = new TimingsHandler(context); handler.addTiming(new_Timing, this.timings_table); }
@Test public void testGetGoldTime() { long gold = 10; Timing timer = new Timing(gold); assertEquals(timer.getGoldTime(), 10); }
@Test public void testValidRunTime() { long gold = 10; Timing timer = new Timing(gold); timer.setStartTime(); timer.setEndTime(); assertFalse(timer.validRunTime()); // gold = 0; // Timing timer2 = new Timing(gold); // assertTrue(timer2.validRunTime()); }
@Override public Timing startTiming() { if (TimingsManager.needsFullReset) { TimingsManager.resetTimings(); } else if (TimingsManager.needsRecheckEnabled) { TimingsManager.recheckEnabled(); } super.startTiming(); return this; }
@Override public void stopTiming() { super.stopTiming(); if (!this.enabled) { return; } if (TimingsHistory.timedTicks % 20 == 0) { final Runtime runtime = Runtime.getRuntime(); double usedMemory = runtime.totalMemory() - runtime.freeMemory(); double freeMemory = runtime.maxMemory() - usedMemory; if (this.avgFreeMemory == -1) { this.avgFreeMemory = freeMemory; } else { this.avgFreeMemory = (this.avgFreeMemory * (59 / 60D)) + (freeMemory * (1 / 60D)); } if (this.avgUsedMemory == -1) { this.avgUsedMemory = usedMemory; } else { this.avgUsedMemory = (this.avgUsedMemory * (59 / 60D)) + (usedMemory * (1 / 60D)); } } long start = System.nanoTime(); TimingsManager.tick(); long diff = System.nanoTime() - start; CURRENT = Timings.timingsTickTimer; Timings.timingsTickTimer.addDiff(diff); // addDiff for timingsTickTimer incremented this, bring it back down to 1 per tick. this.record.curTickCount--; this.minuteData.curTickTotal = this.record.curTickTotal; this.minuteData.curTickCount = 1; boolean violated = isViolated(); this.minuteData.tick(violated); Timings.timingsTickTimer.tick(violated); tick(violated); if (TimingsHistory.timedTicks % 1200 == 0) { MINUTE_REPORTS.add(new TimingsHistory.MinuteReport()); TimingsHistory.resetTicks(false); this.minuteData.reset(); } if (TimingsHistory.timedTicks % Timings.getHistoryInterval() == 0) { TimingsManager.HISTORY.add(new TimingsHistory()); TimingsManager.resetTimings(); } }
@Override protected void addApplicationModules(List<Module> modules) { timing.start(); // Debug.startMethodTracing("dmtrace", 32 * 1024 * 1024); modules.add(new CompassActivityModule()); // +1 second (11.0) modules.add(new GeoBeaglePackageModule()); modules.add(new DatabaseModule()); modules.add(new CacheListModule()); modules.add(new LocationModule()); modules.add(new ModelModule()); modules.add(new GpsStatusWidgetModule()); modules.add(new BCachingModule()); modules.add(new MapModule()); }
public synchronized Response sendRequest(Request request) { setConnected(false); HttpPost post = new HttpPost(serverAddress.toString()); HttpEntity responseEntity = null; Response message = null; ObjectMapper mapper = mapperProvider.getMapper(); messageTiming.reset(); try { if (messageTimingEnabled) messageTiming.startSerialization(); String requestVal = mapper.writeValueAsString(request); if (messageTimingEnabled) messageTiming.endSerialization(); if (messageLog != null) { messageLog.append("//REQUEST\n"); messageLog.append(requestVal + "\n"); messageLog.flush(); } if (messageTimingEnabled) messageTiming.startTransmission(); StringEntity entity = new StringEntity(requestVal); post.setEntity(entity); entity.setContentType("application/json"); HttpResponse response; synchronized (httpClient) { response = httpClient.execute(post); } if (messageTimingEnabled) messageTiming.endTransmission(); if (messageTimingEnabled) messageTiming.startDeserialization(); responseEntity = response.getEntity(); InputStream inStream = responseEntity.getContent(); if (responseEntity.getContentType() != null) { if (messageLog == null) message = mapper.readValue(inStream, Response.class); else { String entityVal = EntityUtils.toString(responseEntity); messageLog.append("//RESPONSE\n"); messageLog.append(entityVal + "\n"); messageLog.flush(); message = mapper.readValue(entityVal, Response.class); } inStream.close(); setConnected(true); } else { throw new ClientException( "Able to connect but response is not from Server. Incorrect URL?"); } } catch (ClientException e) { e.printStackTrace(); message = new ClientErrorResponse(e); } catch (Exception e) { e.printStackTrace(); message = new ClientErrorResponse(e); } finally { try { if (responseEntity != null) responseEntity.consumeContent(); } catch (IOException e) { message = new ClientErrorResponse(e); } } if (messageTimingEnabled) messageTiming.endDeserialization(); return message; }
@Test public void testTiming() { Timing timer = new Timing(); assertEquals(timer.getTotalRunTime(), 0); }
@Test public void testSetEndTime() { Timing timer = new Timing(); timer.setEndTime(); assertNotEquals(timer.endTime, 0); }
/** * Closes Report Usage Windows and enable Atlassian Connector Usage Reporting Window. Did not find * other way how to disable Atlassian Connector Usage Reporting Window displaying * * @param reportJbtUsage * @param reportSubclipseUsage */ public static void manageBlockingWidows(boolean reportJbtUsage, boolean reportSubclipseUsage) { // Manage JBT/JBDS and Subclipse Usage Reporting SWTWorkbenchBot bot = new SWTWorkbenchBot(); SWTBotShell shJbtUsage = null; SWTBotShell shSubclipseUsage = null; bot.sleep(Timing.time5S()); new SWTUtilExt(bot).waitForNonIgnoredJobs(); SWTBotShell[] shells = bot.shells(); int index = 0; while ((shJbtUsage == null || shSubclipseUsage == null) && index < shells.length) { if (shells[index].getText().equals(IDELabel.Shell.JBOSS_DEVELOPER_STUDIO_USAGE) || shells[index].getText().equals(IDELabel.Shell.JBOSS_TOOLS_USAGE)) { shJbtUsage = shells[index]; } else if (shells[index].getText().equals(IDELabel.Shell.SUBCLIPSE_USAGE)) { shSubclipseUsage = shells[index]; } index++; } if (shJbtUsage != null && shJbtUsage.isActive()) { closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage); if (shSubclipseUsage != null) { closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage); } } else if (shSubclipseUsage != null && shSubclipseUsage.isActive()) { closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage); if (shJbtUsage != null) { closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage); } } // Manage Atlassian Connector Usage Reporting try { SWTBot prefBot = new SWTOpenExt(new SWTBotExt()) .preferenceOpen(ActionItem.Preference.AtlassianConnectorUsageData.LABEL); SWTBotCheckBox chbEnableMonitoring = prefBot.checkBox(); if (!chbEnableMonitoring.isChecked()) { chbEnableMonitoring.click(); } prefBot.button(IDELabel.Button.OK).click(); } catch (WidgetNotFoundException wnfe) { // do nothing there is no Atlassian Connector installed } // Get rid of welcome screen. Simple close did not work when run in maven log.debug("Trying to close Welcome Screen"); for (IViewReference viewReference : WorkbenchPartLookup.getInstance().findAllViewReferences()) { if (viewReference.getPartName().equals("Welcome")) { final IViewReference iViewReference = viewReference; Display.syncExec( new Runnable() { @Override public void run() { iViewReference.getPage().hideView(iViewReference); } }); log.debug("Welcome Screen closed"); break; } // ok, Welcome screen not present log.info("Welcome window not present"); } }