List of usage examples for java.util.concurrent TimeUnit MICROSECONDS
TimeUnit MICROSECONDS
To view the source code for java.util.concurrent TimeUnit MICROSECONDS.
Click Source Link
From source file:org.apache.giraph.worker.BspServiceSource.java
@Override public void newSuperstep(SuperstepMetricsRegistry superstepMetrics) { waitRequestsTimer = new GiraphTimer(superstepMetrics, TIMER_WAIT_REQUESTS, TimeUnit.MICROSECONDS); wcPostSuperstepTimer = new GiraphTimer(superstepMetrics, "worker-context-post-superstep", TimeUnit.MICROSECONDS); }
From source file:org.apache.druid.benchmark.FilterPartitionBenchmark.java
@Benchmark @BenchmarkMode(Mode.AverageTime)/*from www . j a va 2 s . com*/ @OutputTimeUnit(TimeUnit.MICROSECONDS) public void readWithExFnPostFilter(Blackhole blackhole) { Filter filter = new NoBitmapSelectorDimFilter("dimSequential", "super-199", JS_EXTRACTION_FN).toFilter(); StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex); Sequence<Cursor> cursors = makeCursors(sa, filter); readCursors(cursors, blackhole); }
From source file:com.linkedin.pinot.perf.BenchmarkOfflineIndexReader.java
@Benchmark @BenchmarkMode(Mode.AverageTime)//from w ww . j av a 2 s .co m @OutputTimeUnit(TimeUnit.MICROSECONDS) public int stringDictionary() { int length = _stringDictionary.length(); int ret = 0; int[] dictIds = new int[NUM_ROUNDS]; for (int i = 0; i < NUM_ROUNDS; i++) { int dictId = RANDOM.nextInt(length); String value = _stringDictionary.getStringValue(dictId); ret += _stringDictionary.indexOf(value); dictIds[i] = dictId; } String[] outValues = new String[NUM_ROUNDS]; _stringDictionary.readStringValues(dictIds, 0, NUM_ROUNDS, outValues, 0); for (int i = 0; i < NUM_ROUNDS; i++) { ret += outValues[0].length(); } return ret; }
From source file:org.apache.druid.benchmark.query.SelectBenchmark.java
@Benchmark @BenchmarkMode(Mode.AverageTime)// www . ja v a2s . co m @OutputTimeUnit(TimeUnit.MICROSECONDS) public void queryQueryableIndex(Blackhole blackhole) { SelectQuery queryCopy = query.withPagingSpec(PagingSpec.newSpec(pagingThreshold)); String segmentId = "qIndex"; QueryRunner<Result<SelectResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, segmentId, new QueryableIndexSegment(segmentId, qIndexes.get(0))); boolean done = false; while (!done) { List<Result<SelectResultValue>> results = SelectBenchmark.runQuery(factory, runner, queryCopy); SelectResultValue result = results.get(0).getValue(); if (result.getEvents().size() == 0) { done = true; } else { for (EventHolder eh : result.getEvents()) { blackhole.consume(eh); } queryCopy = incrementQueryPagination(queryCopy, result); } } }
From source file:com.jkoolcloud.tnt4j.streams.fields.ActivityInfo.java
/** * Formats the value for the field based on the required internal data type of the field and the definition of the * field./*from w ww . j a v a 2 s.c o m*/ * * @param field * field whose value is to be formatted * @param locator * locator information for value * @param value * raw value of field * @return formatted value of field in required internal data type */ protected Object formatValue(ActivityField field, ActivityFieldLocator locator, Object value) { if (value == null) { return null; } if (field.isEnumeration()) { if (value instanceof String) { String strValue = (String) value; value = StringUtils.containsOnly(strValue, "0123456789") ? Integer.valueOf(strValue) // NON-NLS : strValue.toUpperCase().trim(); } } StreamFieldType fieldType = field.getFieldType(); if (fieldType != null) { switch (fieldType) { case ElapsedTime: try { // Elapsed time needs to be converted to usec TimeUnit units = StringUtils.isEmpty(locator.getUnits()) ? TimeUnit.MICROSECONDS : TimeUnit.valueOf(locator.getUnits().toUpperCase()); if (!(value instanceof Number)) { value = Long.valueOf(Utils.toString(value)); } value = TimestampFormatter.convert((Number) value, units, TimeUnit.MICROSECONDS); } catch (Exception e) { } break; case ServerIp: if (value instanceof InetAddress) { value = ((InetAddress) value).getHostAddress(); } break; case ServerName: if (value instanceof InetAddress) { value = ((InetAddress) value).getHostName(); } break; default: break; } } return value; }
From source file:io.druid.benchmark.query.TopNBenchmark.java
@Benchmark @BenchmarkMode(Mode.AverageTime)// w w w . jav a 2s .c o m @OutputTimeUnit(TimeUnit.MICROSECONDS) public void querySingleIncrementalIndex(Blackhole blackhole) throws Exception { QueryRunner<Result<TopNResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, "incIndex", new IncrementalIndexSegment(incIndexes.get(0), "incIndex")); List<Result<TopNResultValue>> results = TopNBenchmark.runQuery(factory, runner, query); for (Result<TopNResultValue> result : results) { blackhole.consume(result); } }
From source file:io.druid.benchmark.FilterPartitionBenchmark.java
@Benchmark @BenchmarkMode(Mode.AverageTime)/* w w w . ja v a 2 s .co m*/ @OutputTimeUnit(TimeUnit.MICROSECONDS) public void readWithPostFilter(Blackhole blackhole) throws Exception { Filter filter = new NoBitmapSelectorFilter("dimSequential", "199"); StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex); Sequence<Cursor> cursors = makeCursors(sa, filter); Sequence<List<String>> stringListSeq = readCursors(cursors, blackhole); List<String> strings = Sequences .toList(Sequences.limit(stringListSeq, 1), Lists.<List<String>>newArrayList()).get(0); for (String st : strings) { blackhole.consume(st); } }
From source file:nl.uva.sne.disambiguators.Wikidata.java
private Map<String, List<String>> getCategories(Set<Term> terms) throws MalformedURLException, InterruptedException, ExecutionException { Map<String, List<String>> cats = new HashMap<>(); if (terms.size() > 0) { int maxT = 2; BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue(maxT); ExecutorService pool = new ThreadPoolExecutor(maxT, maxT, 500L, TimeUnit.MICROSECONDS, workQueue); // ExecutorService pool = new ThreadPoolExecutor(maxT, maxT, // 5000L, TimeUnit.MILLISECONDS, // new ArrayBlockingQueue<>(maxT, true), new ThreadPoolExecutor.CallerRunsPolicy()); Set<Future<Map<String, List<String>>>> set1 = new HashSet<>(); String prop = "P910"; for (Term t : terms) { URL url = new URL( page + "?action=wbgetclaims&format=json&props=&property=" + prop + "&entity=" + t.getUID()); System.err.println(url); WikiRequestor req = new WikiRequestor(url, t.getUID(), 1); Future<Map<String, List<String>>> future = pool.submit(req); set1.add(future);/*from w w w . j ava 2 s. co m*/ } pool.shutdown(); Map<String, List<String>> map = new HashMap<>(); for (Future<Map<String, List<String>>> future : set1) { while (!future.isDone()) { // Logger.getLogger(Wikipedia.class.getName()).log(Level.INFO, "Task is not completed yet...."); Thread.currentThread().sleep(10); } Map<String, List<String>> c = future.get(); if (c != null) { map.putAll(c); } } workQueue = new ArrayBlockingQueue(maxT); pool = new ThreadPoolExecutor(maxT, maxT, 500L, TimeUnit.MICROSECONDS, workQueue); // pool = new ThreadPoolExecutor(maxT, maxT, // 5000L, TimeUnit.MILLISECONDS, // new ArrayBlockingQueue<>(maxT, true), new ThreadPoolExecutor.CallerRunsPolicy()); Set<Future<Map<String, List<String>>>> set2 = new HashSet<>(); for (Term t : terms) { List<String> catIDs = map.get(t.getUID()); for (String catID : catIDs) { URL url = new URL( page + "?action=wbgetentities&format=json&props=labels&languages=en&ids=" + catID); System.err.println(url); WikiRequestor req = new WikiRequestor(url, t.getUID(), 2); Future<Map<String, List<String>>> future = pool.submit(req); set2.add(future); } } pool.shutdown(); for (Future<Map<String, List<String>>> future : set2) { while (!future.isDone()) { // Logger.getLogger(Wikipedia.class.getName()).log(Level.INFO, "Task is not completed yet...."); Thread.currentThread().sleep(10); } Map<String, List<String>> c = future.get(); if (c != null) { cats.putAll(c); } } } return cats; }
From source file:org.apache.druid.benchmark.FilterPartitionBenchmark.java
@Benchmark @BenchmarkMode(Mode.AverageTime)/*from w w w .j a v a2 s . c om*/ @OutputTimeUnit(TimeUnit.MICROSECONDS) public void readAndFilter(Blackhole blackhole) { Filter andFilter = new AndFilter(ImmutableList.of(new SelectorFilter("dimUniform", "199"), new NoBitmapSelectorDimFilter("dimUniform", "super-199", JS_EXTRACTION_FN).toFilter())); StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex); Sequence<Cursor> cursors = makeCursors(sa, andFilter); readCursors(cursors, blackhole); }
From source file:net.centro.rtb.monitoringcenter.MonitoringCenterServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); boolean disableAuthorization = Boolean.TRUE.toString() .equalsIgnoreCase(servletConfig.getInitParameter(DISABLE_AUTHORIZATION_INIT_PARAM)); if (!disableAuthorization) { String credentials = null; String username = servletConfig.getInitParameter(USERNAME_INIT_PARAM); String password = servletConfig.getInitParameter(PASSWORD_INIT_PARAM); if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { credentials = username.trim() + ":" + password.trim(); } else {/*from www . jav a 2 s . c o m*/ credentials = DEFAULT_CREDENTIALS; } this.encodedCredentials = BaseEncoding.base64().encode(credentials.getBytes()); } this.objectMapper = new ObjectMapper() .registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MICROSECONDS, false)) .registerModule(new HealthCheckModule()).setSerializationInclusion(JsonInclude.Include.NON_NULL) .setTimeZone(TimeZone.getDefault()).setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")); this.graphiteMetricFormatter = new GraphiteMetricFormatter(TimeUnit.SECONDS, TimeUnit.MICROSECONDS); try { this.threadDumpGenerator = new ThreadDump(ManagementFactory.getThreadMXBean()); } catch (NoClassDefFoundError ignore) { } ServletContext servletContext = servletConfig.getServletContext(); String servletSpecVersion = servletContext.getMajorVersion() + "." + servletContext.getMinorVersion(); this.serverInfo = ServerInfo.create(servletContext.getServerInfo(), servletSpecVersion); }