List of usage examples for java.lang System currentTimeMillis
@HotSpotIntrinsicCandidate public static native long currentTimeMillis();
From source file:Tester.java
public static void main(String[] args) throws Exception { final String filename = "fcl/generated.fcl"; final String[] linguisticTermNames = { "muuuuuuypeque", "muypeque", "peque", "normal", "grande", "muygrande", "muuuuygrande" }; final RegionDistributionInfo[] linguisticTerms = new RegionDistributionInfo[linguisticTermNames.length]; for (int i = 0; i < linguisticTermNames.length; ++i) linguisticTerms[i] = new RegionDistributionInfo(linguisticTermNames[i], 1.0 / (linguisticTerms.length - 1)); final boolean database = true; System.out.println("Creating dataset " + System.currentTimeMillis()); final MobileDevices mobileDevices = createDataset(database); System.out.println(mobileDevices.getMobileDevices().size()); final Map<DeviceCapability, Variable> inputVariables = new HashMap<DeviceCapability, Variable>(); final Variable realSizeVar = new Variable("real_size", Arrays.asList(linguisticTerms)); final Variable resoSizeVar = new Variable("reso_size", Arrays.asList(linguisticTerms)); inputVariables.put(DeviceCapability.real_size, realSizeVar); inputVariables.put(DeviceCapability.reso_size, resoSizeVar); final Map<String, Variable> outputVariables = new HashMap<String, Variable>(); outputVariables.put("hey", new Variable("hey", Arrays.asList(new RegionDistributionInfo("ho", 1.0 / 2), new RegionDistributionInfo("lets", 1.0 / 2), new RegionDistributionInfo("go", 1.0 / 2)))); final String rules = "// the rules \n"; final FclCreator creator = new FclCreator(); System.out.println("Creating rule file " + System.currentTimeMillis()); final WarningStore warningStore = new WarningStore(); final String fileContent = creator.createRuleFile("prueba", inputVariables, new HashMap<UserCapability, Variable>(), outputVariables, mobileDevices, rules, warningStore); warningStore.print();/*from ww w. j a va 2 s . c o m*/ final File file = new File(filename); file.createNewFile(); System.out.println("Dumping the rule file " + System.currentTimeMillis()); FileUtils.writeStringToFile(file, fileContent); System.out.println("Processing the file " + System.currentTimeMillis()); final FIS fis = FIS.load(filename, true); net.sourceforge.jFuzzyLogic.rule.Variable realSize = fis.getVariable("real_size"); JFreeChart theChart = realSize.chart(false); @SuppressWarnings("unused") BufferedImage img = theChart.createBufferedImage(1000, 1000); /* FileOutputStream fos = new FileOutputStream("imagen.png"); ImageEncoder myEncoder = ImageEncoderFactory.newInstance("png"); myEncoder.encode(img, fos); fos.flush(); fos.close(); */ fis.chart(); }
From source file:com.cloudhopper.sxmp.demo.SubmitMain.java
static public void main(String[] args) throws Exception { String url = "http://127.0.0.1:8080/api/sxmp/1.0"; String phone = "+14155551212"; int operator = 1; if (args.length > 0) url = args[0];/* www. ja v a2 s.c o m*/ if (args.length > 1) phone = args[1]; if (args.length > 2) operator = Integer.parseInt(args[2]); // create a submit request SubmitRequest submit = new SubmitRequest(); submit.setAccount(new Account("customer1", "password1")); submit.setDeliveryReport(Boolean.TRUE); MobileAddress sourceAddr = new MobileAddress(); sourceAddr.setAddress(MobileAddress.Type.NETWORK, "40404"); submit.setSourceAddress(sourceAddr); submit.setOperatorId(operator); submit.setPriority(Priority.URGENT); MobileAddress destAddr = new MobileAddress(); destAddr.setAddress(MobileAddress.Type.INTERNATIONAL, phone); submit.setDestinationAddress(destAddr); submit.setText("Hello World"); // Get file to be posted HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); client.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE); long totalStart = System.currentTimeMillis(); int count = 1; for (int i = 0; i < count; i++) { long start = System.currentTimeMillis(); // execute request try { HttpPost post = new HttpPost(url); //ByteArrayEntity entity = new ByteArrayEntity(data); StringEntity entity = new StringEntity(SxmpWriter.createString(submit)); entity.setContentType("text/xml; charset=\"iso-8859-1\""); post.setEntity(entity); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = client.execute(post, responseHandler); long stop = System.currentTimeMillis(); logger.debug("----------------------------------------"); logger.debug("Response took " + (stop - start) + " ms"); logger.debug(responseBody); logger.debug("----------------------------------------"); } finally { // do nothing } } long totalEnd = System.currentTimeMillis(); logger.debug("Response took " + (totalEnd - totalStart) + " ms for " + count + " requests"); double seconds = ((double) (totalEnd - totalStart)) / 1000; double smspersec = ((double) count) / seconds; logger.debug("SMS / Sec: " + DecimalUtil.toString(smspersec, 2)); }
From source file:com.ciphertool.zodiacengine.CipherSolutionExecutor.java
/** * @param args//from ww w.j a v a 2 s.c o m * @throws InterruptedException */ public static void main(String[] args) throws InterruptedException { // Spin up the Spring application context setUp(); CipherDto cipherDto = null; Cipher cipher = cipherDao.findByCipherName(cipherName); long start = System.currentTimeMillis(); ExecutorService executor = Executors.newFixedThreadPool(maxThreads); cipherDto = new CipherDto(String.valueOf(0), cipher); /* * We want to generate and validate a specific number of solutions, no * matter how long it takes. */ if (applicationDurationType == ApplicationDurationType.ITERATION) { if (numIterations <= 0) { throw new IllegalArgumentException( "ApplicationDurationType set to ITERATION, but numIterations was not set or was set incorrectly."); } log.info("Beginning solution generation. Generating " + numIterations + " solutions using " + maxThreads + " threads."); for (long i = 1; i <= numIterations; i++) { Runnable cipherTask = new CipherSolutionSynchronizedRunnable(solutionGenerator, solutionEvaluator, cipherDto); executor.execute(cipherTask); } // Make executor accept no new threads and finish all existing // threads in the queue executor.shutdown(); } /* * We want to generate and validate solutions for a set amount of time, * no matter how many we can generate in that time period. */ else if (applicationDurationType == ApplicationDurationType.TEMPORAL) { if (applicationRunMillis <= 0) { throw new IllegalArgumentException( "ApplicationDurationType set to TEMPORAL, but applicationRunMillis was not set or was set incorrectly."); } log.info("Beginning solution generation. Generating solutions for " + applicationRunMillis + "ms using " + maxThreads + " threads."); long count = 0; while (true) { Runnable cipherTask = new CipherSolutionSynchronizedRunnable(solutionGenerator, solutionEvaluator, cipherDto); executor.execute(cipherTask); /* * This is a fairly rudimentary way of managing the number of * tasks sent to the executor. * * If we don't manage it somehow, the app will get bogged down * by the continuous while loop and performance will degrade * significantly. */ if (++count >= queueTaskLimit) { count = 0; executor.shutdown(); /* * We are mainly concerned about blocking until all tasks * are finished, so the timeout is not a big concern. */ executor.awaitTermination(1, TimeUnit.MINUTES); executor = Executors.newFixedThreadPool(maxThreads); if ((System.currentTimeMillis() - start) > applicationRunMillis) { break; } } } // Make executor stop immediately executor.shutdownNow(); } // Wait until all threads are finished while (!executor.isTerminated()) { } SolutionChromosome solutionMostMatches = cipherDto.getSolutionMostMatches(); SolutionChromosome solutionMostUnique = cipherDto.getSolutionMostUnique(); SolutionChromosome solutionMostAdjacent = cipherDto.getSolutionMostAdjacent(); /* * Print out summary information */ log.info("Took " + (System.currentTimeMillis() - start) + "ms to generate and validate " + cipherDto.getNumSolutions() + " solutions."); log.info("Highest total matches achieved: " + solutionMostMatches.getTotalMatches()); log.info("Average total matches: " + (cipherDto.getTotalMatchSum() / cipherDto.getNumSolutions())); log.info("Best solution found: " + solutionMostMatches); log.info("Most unique matches achieved: " + solutionMostUnique.getUniqueMatches()); log.info("Average unique matches: " + (cipherDto.getUniqueMatchSum() / cipherDto.getNumSolutions())); log.info("Solution with most unique matches found: " + solutionMostUnique); log.info("Most adjacent matches achieved: " + solutionMostAdjacent.getAdjacentMatchCount()); log.info("Average adjacent matches: " + (cipherDto.getAdjacentMatchSum() / cipherDto.getNumSolutions())); log.info("Solution with most adjacent matches found: " + solutionMostAdjacent); }
From source file:com.qpark.maven.plugin.flowmapper.AbstractGenerator.java
public static void main(final String[] args) { final String basePackageName = "com.qpark.eip.inf"; final String xsdPath = "C:\\xnb\\dev\\git\\EIP\\qp-enterprise-integration-platform-sample\\sample-domain-gen\\domain-gen-flow\\target\\model"; final File dif = new File(xsdPath); final String messagePackageNameSuffix = "mapping flow"; final long start = System.currentTimeMillis(); final XsdsUtil xsds = XsdsUtil.getInstance(dif, "a.b.c.bus", messagePackageNameSuffix, "delta"); final ComplexContentList complexContentList = new ComplexContentList(); complexContentList.setupComplexContentLists(xsds); System.out.println(Util.getDuration(System.currentTimeMillis() - start)); final String eipVersion = "eipVersion"; String source = null;/*from w w w . j av a 2s . com*/ ComplexType ct; ComplexContent cc; SchemaType type; String ctNamespace; String ctName; final SystemStreamLog log = new org.apache.maven.plugin.logging.SystemStreamLog(); ctName = "ApplicationUserLog.networkLongToDoubleTabularMappingType"; ctNamespace = "http://www.samples.com/Interfaces/TechnicalSupportMappingTypes"; // ct = xsds.getComplexType(new QName(ctNamespace, ctName)); // type = ct.getType().getElementProperties()[0].getType(); // cc = complexContentList.getComplexContent(ctNamespace, ctName); // // DirectMappingTypeGenerator mapper = new // DirectMappingTypeGenerator(xsds, // basePackageName, cc, complexContentList, eipVersion, dif, dif, // log); // source = mapper.generateImplContent(); ct = xsds.getComplexType(new QName(ctNamespace, ctName)); type = ct.getType().getElementProperties()[0].getType(); cc = complexContentList.getComplexContent(ctNamespace, ctName); final TabularMappingTypeGenerator directMapper = new TabularMappingTypeGenerator(xsds, basePackageName, cc, complexContentList, ctName, dif, dif, new org.apache.maven.plugin.logging.SystemStreamLog()); source = directMapper.generateImplContent(); System.out.println(source); }
From source file:com.btoddb.fastpersitentqueue.speedtest.SpeedTest.java
public static void main(String[] args) throws Exception { if (0 == args.length) { System.out.println();//from ww w.j av a2 s . c o m System.out.println("ERROR: must specify the config file path/name"); System.out.println(); System.exit(1); } SpeedTestConfig config = SpeedTestConfig.create(args[0]); System.out.println(config.toString()); File theDir = new File(config.getDirectory(), "speed-" + UUID.randomUUID().toString()); FileUtils.forceMkdir(theDir); Fpq queue = config.getFpq(); queue.setJournalDirectory(new File(theDir, "journals")); queue.setPagingDirectory(new File(theDir, "pages")); try { queue.init(); // // start workers // AtomicLong counter = new AtomicLong(); AtomicLong pushSum = new AtomicLong(); AtomicLong popSum = new AtomicLong(); long startTime = System.currentTimeMillis(); Set<SpeedPushWorker> pushWorkers = new HashSet<SpeedPushWorker>(); for (int i = 0; i < config.getNumberOfPushers(); i++) { pushWorkers.add(new SpeedPushWorker(queue, config, counter, pushSum)); } Set<SpeedPopWorker> popWorkers = new HashSet<SpeedPopWorker>(); for (int i = 0; i < config.getNumberOfPoppers(); i++) { popWorkers.add(new SpeedPopWorker(queue, config, popSum)); } ExecutorService pusherExecSrvc = Executors.newFixedThreadPool( config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setName("SpeedTest-Pusher"); return t; } }); ExecutorService popperExecSrvc = Executors.newFixedThreadPool( config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setName("SpeedTest-Popper"); return t; } }); long startPushing = System.currentTimeMillis(); for (SpeedPushWorker sw : pushWorkers) { pusherExecSrvc.submit(sw); } long startPopping = System.currentTimeMillis(); for (SpeedPopWorker sw : popWorkers) { popperExecSrvc.submit(sw); } // // wait to finish // long endTime = startTime + config.getDurationOfTest() * 1000; long endPushing = 0; long displayTimer = 0; while (0 == endPushing || !queue.isEmpty()) { // display status every second if (1000 < (System.currentTimeMillis() - displayTimer)) { System.out.println(String.format("status (%ds) : journals = %d : memory segments = %d", (endTime - System.currentTimeMillis()) / 1000, queue.getJournalMgr().getJournalIdMap().size(), queue.getMemoryMgr().getSegments().size())); displayTimer = System.currentTimeMillis(); } pusherExecSrvc.shutdown(); if (pusherExecSrvc.awaitTermination(100, TimeUnit.MILLISECONDS)) { endPushing = System.currentTimeMillis(); // tell poppers, all pushers are finished for (SpeedPopWorker sw : popWorkers) { sw.stopWhenQueueEmpty(); } } } long endPopping = System.currentTimeMillis(); popperExecSrvc.shutdown(); popperExecSrvc.awaitTermination(10, TimeUnit.SECONDS); long numberOfPushes = 0; for (SpeedPushWorker sw : pushWorkers) { numberOfPushes += sw.getNumberOfEntries(); } long numberOfPops = 0; for (SpeedPopWorker sw : popWorkers) { numberOfPops += sw.getNumberOfEntries(); } long pushDuration = endPushing - startPushing; long popDuration = endPopping - startPopping; System.out.println("push - pop checksum = " + pushSum.get() + " - " + popSum.get() + " = " + (pushSum.get() - popSum.get())); System.out.println("push duration = " + pushDuration); System.out.println("pop duration = " + popDuration); System.out.println(); System.out.println("pushed = " + numberOfPushes); System.out.println("popped = " + numberOfPops); System.out.println(); System.out.println("push entries/sec = " + numberOfPushes / (pushDuration / 1000f)); System.out.println("pop entries/sec = " + numberOfPops / (popDuration / 1000f)); System.out.println(); System.out.println("journals created = " + queue.getJournalsCreated()); System.out.println("journals removed = " + queue.getJournalsRemoved()); } finally { if (null != queue) { queue.shutdown(); } // FileUtils.deleteDirectory(theDir); } }
From source file:BestReplacement.java
public static void main(String[] args) { try {//from w w w . j av a 2s. com BestReplacement br = new BestReplacement(); System.out.println(" just created, br.isAlive()=" + br.isAlive()); Thread.sleep(4200); long startTime = System.currentTimeMillis(); br.suspendRequest(); System.out.println(" just submitted a suspendRequest"); boolean suspensionTookEffect = br.waitForActualSuspension(10000); long stopTime = System.currentTimeMillis(); if (suspensionTookEffect) { System.out.println(" the internal thread took " + (stopTime - startTime) + " ms to notice " + "\n the suspend request and is now " + "suspended."); } else { System.out.println(" the internal thread did not notice " + "the suspend request " + "\n within 10 seconds."); } Thread.sleep(5000); br.resumeRequest(); System.out.println("Submitted a resumeRequest"); Thread.sleep(2200); br.stopRequest(); System.out.println("Submitted a stopRequest"); } catch (InterruptedException x) { // ignore } }
From source file:com.stratio.decision.executables.DataFlowFromCsvMain.java
public static void main(String[] args) throws IOException, NumberFormatException, InterruptedException { if (args.length < 4) { log.info(// w w w . jav a 2s .co m "Usage: \n param 1 - path to file \n param 2 - stream name to send the data \n param 3 - time in ms to wait to send each data \n param 4 - broker list"); } else { Producer<String, String> producer = new Producer<String, String>(createProducerConfig(args[3])); Gson gson = new Gson(); Reader in = new FileReader(args[0]); CSVParser parser = CSVFormat.DEFAULT.parse(in); List<String> columnNames = new ArrayList<>(); for (CSVRecord csvRecord : parser.getRecords()) { if (columnNames.size() == 0) { Iterator<String> iterator = csvRecord.iterator(); while (iterator.hasNext()) { columnNames.add(iterator.next()); } } else { StratioStreamingMessage message = new StratioStreamingMessage(); message.setOperation(STREAM_OPERATIONS.MANIPULATION.INSERT.toLowerCase()); message.setStreamName(args[1]); message.setTimestamp(System.currentTimeMillis()); message.setSession_id(String.valueOf(System.currentTimeMillis())); message.setRequest_id(String.valueOf(System.currentTimeMillis())); message.setRequest("dummy request"); List<ColumnNameTypeValue> sensorData = new ArrayList<>(); for (int i = 0; i < columnNames.size(); i++) { // Workaround Object value = null; try { value = Double.valueOf(csvRecord.get(i)); } catch (NumberFormatException e) { value = csvRecord.get(i); } sensorData.add(new ColumnNameTypeValue(columnNames.get(i), null, value)); } message.setColumns(sensorData); String json = gson.toJson(message); log.info("Sending data: {}", json); producer.send(new KeyedMessage<String, String>(InternalTopic.TOPIC_DATA.getTopicName(), STREAM_OPERATIONS.MANIPULATION.INSERT, json)); log.info("Sleeping {} ms...", args[2]); Thread.sleep(Long.valueOf(args[2])); } } log.info("Program completed."); } }
From source file:com.asakusafw.windgate.bootstrap.WindGateAbort.java
/** * Program entry.//from w w w .j a va 2 s . c o m * @param args program arguments */ public static void main(String... args) { CommandLineUtil.prepareLogContext(); CommandLineUtil.prepareRuntimeContext(); WGLOG.info("I01000"); long start = System.currentTimeMillis(); int status = execute(args); long end = System.currentTimeMillis(); WGLOG.info("I01999", status, end - start); System.exit(status); }
From source file:fi.laverca.examples.EtsiSign.java
/** * The main method//w w w . j a va 2s . c o m * @param args */ public static void main(String[] args) { // Load properties Properties properties = ExampleConf.getProperties(); // Setup SSL log.info("Setting up ssl"); JvmSsl.setSSL(properties.getProperty(ExampleConf.TRUSTSTORE_FILE), properties.getProperty(ExampleConf.TRUSTSTORE_PASSWORD), properties.getProperty(ExampleConf.KEYSTORE_FILE), properties.getProperty(ExampleConf.KEYSTORE_PASSWORD), properties.getProperty(ExampleConf.KEYSTORE_TYPE)); String apId = properties.getProperty(ExampleConf.AP_ID); String apPwd = properties.getProperty(ExampleConf.AP_PASSWORD); // Setup service URLs String msspSignatureUrl = properties.getProperty(ExampleConf.SIGNATURE_URL); String msspStatusUrl = properties.getProperty(ExampleConf.STATUS_URL); String msspReceiptUrl = properties.getProperty(ExampleConf.RECEIPT_URL); // Create client MssClient etsiClient = new MssClient(apId, apPwd, msspSignatureUrl, msspStatusUrl, msspReceiptUrl); String apTransId = "A" + System.currentTimeMillis(); String msisdn = "+35847001001"; // Create DataToBeSigned DTBS dtbs = new DTBS("sign this", DTBS.ENCODING_UTF8); MSS_SignatureReq sigReq = etsiClient.createSignatureRequest(apTransId, // AP Transaction ID msisdn, // MSISDN dtbs, // Data to be signed null, // Data to be displayed SignatureProfiles.FICOM_SIGNATURE, // Signature profile MSS_Formats.PKCS7, // MSS Format MessagingModeType.SYNCH); // Messaging Mode MSS_SignatureResp sigResp = null; try { sigResp = etsiClient.send(sigReq); } catch (AxisFault af) { log.error("Got SOAP fault", af); return; } catch (IOException ioe) { log.error("Got IOException ", ioe); return; } log.info("Got response"); log.info(" StatusCode : " + sigResp.getStatus().getStatusCode().getValue()); log.info(" StatusMessage: " + sigResp.getStatus().getStatusMessage()); }
From source file:com.cloudhopper.sxmp.DeliverMain.java
static public void main(String[] args) throws Exception { // create a deliver request DeliverRequest deliver = new DeliverRequest(); deliver.setAccount(new Account("customer1", "password1")); deliver.setOperatorId(2);/*from w w w . jav a 2s . c o m*/ MobileAddress sourceAddr = new MobileAddress(); sourceAddr.setAddress(MobileAddress.Type.INTERNATIONAL, "+13135551212"); deliver.setSourceAddress(sourceAddr); MobileAddress destAddr = new MobileAddress(); destAddr.setAddress(MobileAddress.Type.NETWORK, "55555"); deliver.setDestinationAddress(destAddr); deliver.setText( "This is a new message that I want to send that's a little larger than normal &!#@%20*()$#@!~"); // target url //String url = "http://localhost:9080/api/sxmp/1.0"; //String url = "http://lyn-stratus-001/api/sxmp/1.0"; //String url = "http://localhost:9080/api/sxmp/1.0"; //String strURL = "http://sfd-twtr-gw.cloudhopper.com/api/sxmp/1.0"; String url = "http://lyn-stratus-lab5:9080/api/sxmp/1.0"; // Get file to be posted HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); client.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE); // convert request into a byte array //byte[] data = SxmpWriter.createByteArray(submit); //logger.debug(StringUtil.toHexString(data)); long totalStart = System.currentTimeMillis(); int count = 5000; for (int i = 0; i < count; i++) { long start = System.currentTimeMillis(); // execute request try { HttpPost post = new HttpPost(url); //ByteArrayEntity entity = new ByteArrayEntity(data); StringEntity entity = new StringEntity(SxmpWriter.createString(deliver)); entity.setContentType("text/xml; charset=\"iso-8859-1\""); post.setEntity(entity); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = client.execute(post, responseHandler); long stop = System.currentTimeMillis(); logger.debug("----------------------------------------"); logger.debug("Response took " + (stop - start) + " ms"); logger.debug(responseBody); logger.debug("----------------------------------------"); } finally { // do nothing } } long totalEnd = System.currentTimeMillis(); logger.debug("Response took " + (totalEnd - totalStart) + " ms for " + count + " requests"); double seconds = ((double) (totalEnd - totalStart)) / 1000; double smspersec = ((double) count) / seconds; logger.debug("SMS / Sec: " + DecimalUtil.toString(smspersec, 2)); }