List of usage examples for java.lang System nanoTime
@HotSpotIntrinsicCandidate public static native long nanoTime();
From source file:com.spidertracks.datanucleus.CassandraTest.java
/** * Delete all rows in the CF//from w ww. jav a2s. c o m * * @param cfName */ protected void deleteAllRows(String cfName) { int maxSize = 100; Selector selector = Pelops.createSelector("TestPool"); SlicePredicate predicate = Selector.newColumnsPredicateAll(false); RowDeletor deletor = Pelops.createRowDeletor("TestPool", System.nanoTime() / 1000); Bytes lastKey = Bytes.fromByteArray(new byte[] {}); Map<Bytes, List<Column>> results = null; do { KeyRange range = new KeyRange(); range.setStart_key(lastKey.toByteArray()); range.setEnd_key(new byte[] {}); range.setCount(maxSize); results = selector.getColumnsFromRows(cfName, range, predicate, ConsistencyLevel.QUORUM); for (Bytes key : results.keySet()) { deletor.deleteRow(cfName, key, ConsistencyLevel.QUORUM); lastKey = key; } } while (results.size() == maxSize); }
From source file:com.github.seleniumpm.Selenium10.java
public Selenium waitForVisible(Object locator, long waitTime) throws NotFoundException { long currentTime = System.nanoTime(); long endTime = currentTime + TimeUnit.MILLISECONDS.toNanos(elementWaitTime); while (currentTime <= endTime) { if (isVisible(locator)) return this; try {/* w ww .ja va 2 s .co m*/ Thread.sleep(sleepTimeInMilis); } catch (InterruptedException ie) { throw new NotFoundException("An InterruptedException occured!"); } currentTime = System.nanoTime(); } throw new NotFoundException(locator + "was not visible in " + elementWaitTime + "ms!"); }
From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.HttpMethodSupport.java
public void afterWriteRequest(HttpState arg0, HttpConnection arg1) { if (startTime == 0) startTime = System.nanoTime(); }
From source file:br.upe.ecomp.doss.algorithm.abc.ABC.java
private void sendEmployedBees() { MersenneTwister random = new MersenneTwister(System.nanoTime()); double[] tempFood; double tempFitness; for (int i = 0; i < foodCount; i++) { double rand = random.nextDouble() * 32767 / ((double) (32767) + (double) (1)); int param2change = (int) (rand * dimensions); rand = random.nextDouble() * 32767 / ((double) (32767) + (double) (1)); int neighbour = (int) (rand * foodCount); tempFood = new double[dimensions]; for (int j = 0; j < dimensions; j++) { tempFood[j] = foodSources[i].getCurrentPosition()[j]; }/*from ww w .j a v a 2 s .com*/ rand = random.nextDouble() * 32767 / ((double) (32767) + (double) (1)); tempFood[param2change] = foodSources[i].getCurrentPosition()[param2change] + (foodSources[i].getCurrentPosition()[param2change] - foodSources[neighbour].getCurrentPosition()[param2change]) * (rand - 0.5) * 2; if (tempFood[param2change] < getProblem().getLowerBound(dimensions)) tempFood[param2change] = getProblem().getLowerBound(dimensions); if (tempFood[param2change] > getProblem().getUpperBound(dimensions)) tempFood[param2change] = getProblem().getUpperBound(dimensions); tempFitness = getProblem().getFitness(tempFood); if (getProblem().isFitnessBetterThan(foodSources[i].getCurrentFitness(), tempFitness)) { foodSources[i].updateCurrentPosition(tempFood, tempFitness); foodSources[i].updateBestPosition(tempFood, tempFitness); foodSources[i].setCountStagnation(0); double bestSolutionFitness = getProblem().getFitness(solution); if (getProblem().isFitnessBetterThan(bestSolutionFitness, tempFitness)) { solution = tempFood; } } else { foodSources[i].setCountStagnation(foodSources[i].getCountStagnation() + 1); } } }
From source file:de.zib.sfs.WrappedFSDataInputStream.java
@Override public int read(byte[] b) throws IOException { long startTime = System.nanoTime(); int result = this.in.read(b); String datanodeHostname = getDatanodeHostNameString(); this.aggregator.aggregateReadDataOperationStatistics(OperationSource.SFS, OperationCategory.READ, startTime, System.nanoTime(), this.fd, result == -1 ? 0 : result, this.hostname.equals(datanodeHostname) || "localhost".equals(datanodeHostname)); return result; }
From source file:com.linkedin.pinot.perf.StringDictionaryPerfTest.java
/** * Helper method to build a segment://from w w w . j a v a 2 s . c o m * <ul> * <li> Segment contains one string column </li> * <li> Row values for the column are randomly generated strings of length 1 to 100 </li> * </ul> * * @param dictLength Length of the dictionary * @throws Exception */ public void buildSegment(int dictLength) throws Exception { Schema schema = new Schema(); String segmentName = "perfTestSegment" + System.currentTimeMillis(); _indexDir = new File(TMP_DIR + File.separator + segmentName); _indexDir.deleteOnExit(); FieldSpec fieldSpec = new DimensionFieldSpec(COLUMN_NAME, FieldSpec.DataType.STRING, true); schema.addField(fieldSpec); _dictLength = dictLength; _inputStrings = new String[dictLength]; SegmentGeneratorConfig config = new SegmentGeneratorConfig(schema); config.setOutDir(_indexDir.getParent()); config.setFormat(FileFormat.AVRO); config.setSegmentName(segmentName); Random random = new Random(System.nanoTime()); final List<GenericRow> data = new ArrayList<>(); Set<String> uniqueStrings = new HashSet<>(dictLength); int i = 0; while (i < dictLength) { HashMap<String, Object> map = new HashMap<>(); String randomString = RandomStringUtils.randomAlphanumeric(1 + random.nextInt(MAX_STRING_LENGTH)); if (uniqueStrings.contains(randomString)) { continue; } _inputStrings[i] = randomString; uniqueStrings.add(randomString); map.put("test", _inputStrings[i++]); GenericRow genericRow = new GenericRow(); genericRow.init(map); data.add(genericRow); } SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl(); RecordReader reader = getGenericRowRecordReader(schema, data); driver.init(config, reader); driver.build(); }
From source file:net.sourceforge.subsonic.dao.AbstractDao.java
protected <T> List<T> namedQuery(String sql, RowMapper rowMapper, Map<String, Object> args) { long t = System.nanoTime(); List<T> result = getNamedParameterJdbcTemplate().query(sql, args, rowMapper); log(sql, t);// w w w . j a v a 2 s. c om return result; }
From source file:no.ntnu.okse.core.subscription.Subscriber.java
/** * Private method that generates an MD5 subscriber ID * * @return A string containing the generated subscriber ID *//*from w w w. j a v a 2 s. c om*/ private String generateSubscriberID() { try { MessageDigest m = MessageDigest.getInstance("MD5"); m.update(Long.toString(System.nanoTime()).getBytes()); byte[] hash = m.digest(); String topicID = new String(Hex.encode(hash)); return topicID; } catch (NoSuchAlgorithmException e) { log.error("Could not generate a subscriber ID (MD5 algorithm not found)"); } return null; }
From source file:cn.ctyun.amazonaws.util.AWSRequestMetrics.java
/** * Start an event which will be timed. The startTime and endTime are added to timingInfo only after * endEvent is called. For every startEvent there should be a corresponding endEvent. If you start the * same event without ending it, this will overwrite the old event. i.e. There is no support for recursive * events yet. Having said that, if you start and end an event in that sequence multiple times, all events * are logged in timingInfo in that order. * /*from w w w .ja v a2 s.c om*/ * This feature is enabled only if the system property "com.amazonaws.sdk.enableRuntimeProfiling" is set. * * @param eventName - The name of the event to start */ public void startEvent(String eventName) { if (profilingSystemPropertyEnabled) { /* This will overwrite past events */ eventsBeingProfiled.put(eventName, System.nanoTime()); } }