List of usage examples for java.lang System nanoTime
@HotSpotIntrinsicCandidate public static native long nanoTime();
From source file:org.alfresco.module.daos.mongo.MongoNodeDAOImplTest.java
private NodeRef createNode() { AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_TEST, "" + System.nanoTime()); NodeRef rootNodeRef = nodeService.getRootNode(storeRef); NodeRef nodeRef = nodeService/*from w w w . java2 s. c o m*/ .createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.ALFRESCO_URI, "testNode"), ContentModel.TYPE_CONTENT) .getChildRef(); return nodeRef; }
From source file:com.produban.openbus.processor.function.ParseJSON.java
@Override public final void execute(final TridentTuple tuple, final TridentCollector collector) { try {/* w ww . j ava2s .com*/ String decoded = new String(tuple.getBinary(0)); JSONObject json = new JSONObject(decoded); // Date message DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); String dateNow = dateFormat.format(cal.getTime()); json.accumulate("date", dateNow); LOG.info("##### name: " + json.get("name") + " type: " + json.get("type") + " date: " + json.getString("date")); // Persitence in HDFS hDFSStore.writeFile2HDFS("json" + "_" + System.nanoTime(), json.toString()); collector.emit(new Values(json.getString("name"), json.getString("type"))); } catch (Exception e) { LOG.error("Caught JSONException: " + e.getMessage()); throw new RuntimeException(e); } }
From source file:br.com.webbudget.infraestructure.configuration.ApplicationUtils.java
/** * Gera um codigo aleatorio baseado em marcas do tempo * * @param size o tamanho//from www . j av a 2s . c o m * @param onlyNumbers se deve ou nao usar somente numeros * @return o codigo */ public static String createRamdomCode(int size, boolean onlyNumbers) { final String digits; if (onlyNumbers) { digits = "0123456789"; } else { digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } long decimalNumber = System.nanoTime(); String generated = ""; int mod; int authCodeLength = 0; while (decimalNumber != 0 && authCodeLength < size) { mod = (int) (decimalNumber % digits.length()); generated = digits.substring(mod, mod + 1) + generated; decimalNumber = decimalNumber / digits.length(); authCodeLength++; } return generated; }
From source file:com.netflix.genie.core.jobs.workflow.impl.CommandTask.java
/** * {@inheritDoc}/*from ww w. jav a2 s . c o m*/ */ @Override public void executeTask(@NotNull final Map<String, Object> context) throws GenieException, IOException { final long start = System.nanoTime(); try { final JobExecutionEnvironment jobExecEnv = (JobExecutionEnvironment) context .get(JobConstants.JOB_EXECUTION_ENV_KEY); final String jobWorkingDirectory = jobExecEnv.getJobWorkingDir().getCanonicalPath(); final String genieDir = jobWorkingDirectory + JobConstants.FILE_PATH_DELIMITER + JobConstants.GENIE_PATH_VAR; final Writer writer = (Writer) context.get(JobConstants.WRITER_KEY); log.info("Starting Command Task for job {}", jobExecEnv.getJobRequest().getId()); final String commandId = jobExecEnv.getCommand().getId() .orElseThrow(() -> new GeniePreconditionException("No command id found")); // Create the directory for this command under command dir in the cwd createEntityInstanceDirectory(genieDir, commandId, AdminResources.COMMAND); // Create the config directory for this id createEntityInstanceConfigDirectory(genieDir, commandId, AdminResources.COMMAND); // Get the setup file if specified and add it as source command in launcher script final Optional<String> setupFile = jobExecEnv.getCommand().getSetupFile(); if (setupFile.isPresent()) { final String commandSetupFile = setupFile.get(); if (StringUtils.isNotBlank(commandSetupFile)) { final String localPath = super.buildLocalFilePath(jobWorkingDirectory, commandId, commandSetupFile, FileType.SETUP, AdminResources.COMMAND); fts.getFile(commandSetupFile, localPath); super.generateSetupFileSourceSnippet(commandId, "Command:", localPath, writer, jobWorkingDirectory); } } // Iterate over and get all configuration files for (final String configFile : jobExecEnv.getCommand().getConfigs()) { final String localPath = super.buildLocalFilePath(jobWorkingDirectory, commandId, configFile, FileType.CONFIG, AdminResources.COMMAND); fts.getFile(configFile, localPath); } log.info("Finished Command Task for job {}", jobExecEnv.getJobRequest().getId()); } finally { final long finish = System.nanoTime(); this.timer.record(finish - start, TimeUnit.NANOSECONDS); } }
From source file:com.netflix.genie.core.jobs.workflow.impl.ClusterTask.java
/** * {@inheritDoc}//www.j av a 2s . c o m */ @Override public void executeTask(@NotNull final Map<String, Object> context) throws GenieException, IOException { final long start = System.nanoTime(); try { final JobExecutionEnvironment jobExecEnv = (JobExecutionEnvironment) context .get(JobConstants.JOB_EXECUTION_ENV_KEY); final String jobWorkingDirectory = jobExecEnv.getJobWorkingDir().getCanonicalPath(); final String genieDir = jobWorkingDirectory + JobConstants.FILE_PATH_DELIMITER + JobConstants.GENIE_PATH_VAR; final Writer writer = (Writer) context.get(JobConstants.WRITER_KEY); log.info("Starting Cluster Task for job {}", jobExecEnv.getJobRequest().getId()); final String clusterId = jobExecEnv.getCluster().getId() .orElseThrow(() -> new GeniePreconditionException("No cluster id found")); // Create the directory for this application under applications in the cwd createEntityInstanceDirectory(genieDir, clusterId, AdminResources.CLUSTER); // Create the config directory for this id createEntityInstanceConfigDirectory(genieDir, clusterId, AdminResources.CLUSTER); // Get the set up file for cluster and add it to source in launcher script final Optional<String> setupFile = jobExecEnv.getCluster().getSetupFile(); if (setupFile.isPresent()) { final String clusterSetupFile = setupFile.get(); if (StringUtils.isNotBlank(clusterSetupFile)) { final String localPath = super.buildLocalFilePath(jobWorkingDirectory, clusterId, clusterSetupFile, FileType.SETUP, AdminResources.CLUSTER); fts.getFile(clusterSetupFile, localPath); super.generateSetupFileSourceSnippet(clusterId, "Cluster:", localPath, writer, jobWorkingDirectory); } } // Iterate over and get all configuration files for (final String configFile : jobExecEnv.getCluster().getConfigs()) { final String localPath = super.buildLocalFilePath(jobWorkingDirectory, clusterId, configFile, FileType.CONFIG, AdminResources.CLUSTER); fts.getFile(configFile, localPath); } log.info("Finished Cluster Task for job {}", jobExecEnv.getJobRequest().getId()); } finally { final long finish = System.nanoTime(); this.timer.record(finish - start, TimeUnit.NANOSECONDS); } }
From source file:com.github.rinde.gpem17.evo.StatsLogger.java
public StatsLogger() { startTime = System.nanoTime(); }
From source file:com.linkedin.pinot.index.readerwriter.FixedByteSingleValueMultiColumnReaderWriterTest.java
@BeforeClass public void setup() { _memoryManager = new DirectMemoryManager(FixedByteSingleColumnSingleValueReaderWriterTest.class.getName()); _readerWriter = new FixedByteSingleValueMultiColumnReaderWriter(NUM_ROWS_PER_CHUNK, COLUMN_SIZES_IN_BYTES, _memoryManager, "test"); _random = new Random(System.nanoTime()); }
From source file:infrascructure.data.launch.SimpleDocsRepository.java
@Override public List<String> getCurrentVocabulary() throws IOException { long startTime = System.nanoTime(); String path = config.getProperty(Config.VOCABULARY_PATH); List<String> result = IOHelper.readLinesFromFile(path); long diff = System.nanoTime() - startTime; Trace.trace("[getCurrentVocabulary]: " + diff); return result; }
From source file:com.alibaba.json.test.Bug_0_Test.java
private void f_jackson() throws Exception { long startNano = System.nanoTime(); for (int i = 0; i < COUNT; ++i) { ObjectMapper mapper = new ObjectMapper(); ArrayNode node = (ArrayNode) mapper.readTree(text); JsonNode head = node.get(0);/* w w w .j a v a 2s . c o m*/ JsonNode body = node.get(1); } long nano = System.nanoTime() - startNano; System.out.println(NumberFormat.getInstance().format(nano)); }
From source file:org.messic.server.api.APIRandomLists.java
@Transactional public List<RandomList> getAllLists(User user) { ArrayList<RandomList> result = new ArrayList<RandomList>(); // we will get only 4 lists as maximum, each time different ones... so lets shuffle the lists long seed = System.nanoTime(); ArrayList<RandomListPlugin> lplugins = new ArrayList<RandomListPlugin>(); for (int i = 0; i < plugins.length; i++) { lplugins.add(plugins[i]);/*from www .j ava2s . c om*/ } Collections.shuffle(lplugins, new Random(seed)); for (int i = 0; i < lplugins.size() && i < 4; i++) { long start = System.currentTimeMillis(); RandomListPlugin rlp = lplugins.get(i); RandomList rl = rlp.getRandomList(user); if (rl != null && rl.getSongs().size() > 0) { result.add(rl); } long end = System.currentTimeMillis(); log.debug("(" + ((end - start)) + "ms)-Timing obtaining info from plugin:" + rlp.getName()); } return result; }