List of usage examples for java.lang System currentTimeMillis
@HotSpotIntrinsicCandidate public static native long currentTimeMillis();
From source file:com.feedzai.fos.server.Runner.java
/** * Launches the server./*from ww w . jav a 2s . c om*/ * See @{link StartupConfiguration} for command line switches. * <p/> Will start an embedded RMI registry if "-s" was specified. * * @param args the command line switches * @throws ConfigurationException */ public static void main(String... args) throws ConfigurationException { long time = System.currentTimeMillis(); StartupConfiguration parameters = new StartupConfiguration(); JCommander jCommander = new JCommander(parameters); FosServer fosServer; try { jCommander.parse(args); logger.info("Starting fos server using configuration from {}", parameters.getConfiguration()); FosConfig serverConfig = new FosConfig(new PropertiesConfiguration(parameters.getConfiguration())); if (serverConfig.isEmbeddedRegistry()) { LocateRegistry.createRegistry(serverConfig.getRegistryPort()); logger.debug("RMI registry started in port {}", serverConfig.getRegistryPort()); } fosServer = new FosServer(serverConfig); fosServer.bind(); logger.info("FOS Server started in {}ms", (System.currentTimeMillis() - time)); } catch (ParameterException e) { jCommander.usage(); } catch (Exception e) { logger.error("Could not launch RMI service", e); } }
From source file:module.entities.UsernameChecker.CheckOpengovUsernames.java
/** * @param args the command line arguments *//*w w w. j a v a 2s . c om*/ public static void main(String[] args) throws SQLException, IOException { // args = new String[1]; // args[0] = "searchConf.txt"; Date d = new Date(); long milTime = d.getTime(); long execStart = System.nanoTime(); Timestamp startTime = new Timestamp(milTime); long lStartTime; long lEndTime = 0; int status_id = 1; JSONObject obj = new JSONObject(); if (args.length != 1) { System.out.println("None or too many argument parameters where defined! " + "\nPlease provide ONLY the configuration file name as the only argument."); } else { try { configFile = args[0]; initLexicons(); Database.init(); lStartTime = System.currentTimeMillis(); System.out.println("Opengov username identification process started at: " + startTime); usernameCheckerId = Database.LogUsernameChecker(lStartTime); TreeMap<Integer, String> OpenGovUsernames = Database.GetOpenGovUsers(); HashSet<ReportEntry> report_names = new HashSet<>(); if (OpenGovUsernames.size() > 0) { for (int userID : OpenGovUsernames.keySet()) { String DBusername = Normalizer .normalize(OpenGovUsernames.get(userID).toUpperCase(locale), Normalizer.Form.NFD) .replaceAll("\\p{M}", ""); String username = ""; int type; String[] splitUsername = DBusername.split(" "); if (checkNameInLexicons(splitUsername)) { for (String splText : splitUsername) { username += splText + " "; } type = 1; } else if (checkOrgInLexicons(splitUsername)) { for (String splText : splitUsername) { username += splText + " "; } type = 2; } else { username = DBusername; type = -1; } ReportEntry cerEntry = new ReportEntry(userID, username.trim(), type); report_names.add(cerEntry); } status_id = 2; obj.put("message", "Opengov username checker finished with no errors"); obj.put("details", ""); Database.UpdateOpengovUsersReportName(report_names); lEndTime = System.currentTimeMillis(); } else { status_id = 2; obj.put("message", "Opengov username checker finished with no errors"); obj.put("details", "No usernames needed to be checked"); lEndTime = System.currentTimeMillis(); } } catch (Exception ex) { System.err.println(ex.getMessage()); status_id = 3; obj.put("message", "Opengov username checker encountered an error"); obj.put("details", ex.getMessage().toString()); lEndTime = System.currentTimeMillis(); } } long execEnd = System.nanoTime(); long executionTime = (execEnd - execStart); System.out.println("Total process time: " + (((executionTime / 1000000) / 1000) / 60) + " minutes."); Database.UpdateLogUsernameChecker(lEndTime, status_id, usernameCheckerId, obj); Database.closeConnection(); }
From source file:com.apexxs.neonblack.setup.Setup.java
public static void main(String[] args) { Configuration config = Configuration.getInstance(); SolrLoader solrLoader = null;/*from w w w. j a v a2 s.co m*/ int count = 0; SolrUtilities solrUtilities = new SolrUtilities(); if (!solrUtilities.checkCoreStatus("geonames")) { logger.error("Unable to establish connection to geonames core - Application terminated"); System.exit(-1); } if (!solrUtilities.checkCoreStatus("geodata")) { logger.error("Unable to establish connection to geodata core - Application terminated"); System.exit(-1); } logger.warn("Solr geonames and geodata indices will be cleared..."); SolrUtilities sutil = new SolrUtilities(); // sutil.clearSolrIndices(); long startTime = System.currentTimeMillis(); try { SolrServerFactory solrServerFactory = new SolrServerFactory(); SolrServer server = solrServerFactory.getConcurrentSolrServer("geonames"); // GeoNamesLoader geoNamesLoader = new GeoNamesLoader(); // System.out.println("***Loading Geonames gazetteer***"); // count = geoNamesLoader.load(server); // System.out.println("Committing and optimizing Geonames index...."); // server.commit(); // server.optimize(); // // System.out.println("Geonames index complete - inserted " + count + " documents."); server = solrServerFactory.getHTTPServer("geodata"); if (StringUtils.equalsIgnoreCase(config.getPolygonType(), "gadm")) { System.out.println("***Loading GADM Border polygons***"); solrLoader = new GADMBorderLoader(); count = solrLoader.load(server); } else if (StringUtils.equalsIgnoreCase(config.getPolygonType(), "ne")) { System.out.println("***Loading Natural Earth Border polygons***"); solrLoader = new NaturalEarthLoader(); count = solrLoader.load(server); } else { System.out.println("***Loading Thematicmapping polygons***"); solrLoader = new TMBorderLoader(); count = solrLoader.load(server); solrLoader = new StateBorderLoader(); count += solrLoader.load(server); } System.out.println("Committing and optimizing Geodata index...."); server.commit(); server.optimize(); server.shutdown(); System.out.println("***Loaded " + count + " polygons***"); } catch (Exception ex) { logger.error("Error loading SOLR indices - " + ex.getMessage()); } long endTime = System.currentTimeMillis(); System.out.println("***Solr Index load complete***"); System.out.println("Elapsed time: " + (endTime - startTime) / 60000 + " minutes"); }
From source file:com.siva.javamultithreading.MultiThreadExecutor.java
public static void main(String[] args) throws ExecutionException, IOException { //Populate the data List<DomainObject> list = new ArrayList<>(); DomainObject object = null;/*from w ww . j a v a 2s . c o m*/ for (int i = 0; i < 230000; i++) { object = new DomainObject(); object.setId("ID" + i); object.setName("NAME" + i); object.setComment("COMMENT" + i); list.add(object); } int maxNoOfRows = 40000; int noOfThreads = 1; int remaining = 0; if (list.size() > 40000) { noOfThreads = list.size() / maxNoOfRows; remaining = list.size() % maxNoOfRows; if (remaining > 0) { noOfThreads++; } } List<List<DomainObject>> dos = ListUtils.partition(list, maxNoOfRows); ExecutorService threadPool = Executors.newFixedThreadPool(noOfThreads); CompletionService<HSSFWorkbook> pool = new ExecutorCompletionService<>(threadPool); // Excel creation through multiple threads long startTime = System.currentTimeMillis(); for (List<DomainObject> listObj : dos) { pool.submit(new ExcelChunkSheetWriter(listObj)); } HSSFWorkbook hSSFWorkbook = null; HSSFWorkbook book = new HSSFWorkbook(); HSSFSheet sheet = book.createSheet("Report"); try { for (int i = 0; i < 5; i++) { hSSFWorkbook = pool.take().get(); System.out.println( "sheet row count : sheet.PhysicalNumberOfRows() = " + sheet.getPhysicalNumberOfRows()); int currentCount = sheet.getPhysicalNumberOfRows(); int incomingCount = hSSFWorkbook.getSheetAt(0).getPhysicalNumberOfRows(); if ((currentCount + incomingCount) > 60000) { sheet = book.createSheet("Report" + i); } ExcelUtil.copySheets(book, sheet, hSSFWorkbook.getSheetAt(0)); } } catch (InterruptedException ex) { Logger.getLogger(MultiThreadExecutor.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(MultiThreadExecutor.class.getName()).log(Level.SEVERE, null, ex); } try { writeFile(book, new FileOutputStream("Report.xls")); } catch (Exception e) { e.printStackTrace(); } //System.out.println("No of Threads : " + noOfThreads + " Size : " + list.size() + " remaining : " + remaining); long endTime = System.currentTimeMillis(); System.out.println("Time taken: " + (endTime - startTime) + " ms"); threadPool.shutdown(); //startProcess(); }
From source file:com.nubits.nubot.launch.toolkit.NuCMC.java
public static void main(String[] args) { mainThread = Thread.currentThread(); String folderName = "NuCMC_" + System.currentTimeMillis() + "/"; String logsFolder = Settings.LOGS_PATH + "/" + folderName; //Create log dir FilesystemUtils.mkdir(logsFolder);// ww w .j a v a 2 s. c o m NuCMC app = new NuCMC(); if (app.readParams(args)) { createShutDownHook(); LOG.info("Launching NuCheckPrice "); app.exec(); } else { System.exit(0); } }
From source file:com.dreamerpartner.codereview.lucene.IndexHelper.java
public static void main(String[] args) { long beginTime = System.currentTimeMillis(); try {//from ww w .j a v a 2s . c om List<Document> docs = new ArrayList<Document>(); List<Field[]> list = getTestData(); for (Field[] fields : list) { Document doc = new Document(); for (Field field : fields) { doc.add(field); } docs.add(doc); } adds("test", docs); } catch (IOException e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } finally { long endTime = System.currentTimeMillis(); logger.debug("main " + (endTime - beginTime) + " milliseconds."); } }
From source file:com.genentech.retrival.tabExport.TABExporter.java
public static void main(String[] args) throws ParseException, JDOMException, IOException { long start = System.currentTimeMillis(); int nStruct = 0; // create command line Options object Options options = new Options(); Option opt = new Option("sqlFile", true, "sql-xml file"); opt.setRequired(true);//from w w w . java 2s . c o m options.addOption(opt); opt = new Option("sqlName", true, "name of SQL element in xml file"); opt.setRequired(true); options.addOption(opt); opt = new Option("o", true, "output file"); opt.setRequired(false); options.addOption(opt); opt = new Option("newLineReplacement", true, "If given newlines in fields will be replaced by this string."); options.addOption(opt); opt = new Option("noHeader", false, "Do not output header line"); options.addOption(opt); CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); String outFile = cmd.getOptionValue("o"); String sqlFile = cmd.getOptionValue("sqlFile"); String sqlName = cmd.getOptionValue("sqlName"); String newLineReplacement = cmd.getOptionValue("newLineReplacement"); args = cmd.getArgs(); try { PrintStream out = System.out; if (outFile != null) out = new PrintStream(outFile); SQLStatement stmt = SQLStatement.createFromFile(new File(sqlFile), sqlName); Object[] sqlArgs = args; if (stmt.getParamTypes().length != args.length) { System.err.printf( "\nWarining sql statement needs %d parameters but got only %d. Filling up with NULLs.\n", stmt.getParamTypes().length, args.length); sqlArgs = new Object[stmt.getParamTypes().length]; System.arraycopy(args, 0, sqlArgs, 0, args.length); } Selecter sel = Selecter.factory(stmt); if (!sel.select(sqlArgs)) { System.err.println("No rows returned!"); System.exit(0); } String[] fieldNames = sel.getFieldNames(); if (fieldNames.length == 0) { System.err.println("Query did not return any columns"); exitWithHelp(options); } if (!cmd.hasOption("noHeader")) { StringBuilder sb = new StringBuilder(200); for (String f : fieldNames) sb.append(f).append('\t'); if (sb.length() > 1) sb.setLength(sb.length() - 1); // chop last \t String header = sb.toString(); out.println(header); } StringBuilder sb = new StringBuilder(200); while (sel.hasNext()) { Record sqlRec = sel.next(); sb.setLength(0); for (int i = 0; i < fieldNames.length; i++) { String fld = sqlRec.getStrg(i); if (newLineReplacement != null) fld = NEWLinePattern.matcher(fld).replaceAll(newLineReplacement); sb.append(fld).append('\t'); } if (sb.length() > 1) sb.setLength(sb.length() - 1); // chop last \t String row = sb.toString(); out.println(row); nStruct++; } } catch (Exception e) { throw new Error(e); } finally { System.err.printf("TABExporter: Exported %d records in %dsec\n", nStruct, (System.currentTimeMillis() - start) / 1000); } }
From source file:au.org.ala.layers.stats.ObjectsStatsGenerator.java
public static void main(String[] args) { long start = System.currentTimeMillis(); String fid = null;/*from w w w . j a v a 2 s . co m*/ logger.info( "args[0] = threadcount, args[1] = db connection string, args[2] = db username, args[3] = password"); if (args.length >= 4) { CONCURRENT_THREADS = Integer.parseInt(args[0]); db_url = args[1]; db_usr = args[2]; db_pwd = args[3]; } if (args.length > 4) { fid = args[4]; } Connection c = getConnection(); //String count_sql = "select count(*) as cnt from objects where bbox is null or area_km is null"; String count_sql = "select count(*) as cnt from objects where area_km is null and st_geometrytype(the_geom) <> 'ST_Point' "; if (StringUtils.isEmpty(fid)) { count_sql = count_sql + " and fid = '" + fid + "'"; } int count = 0; try { Statement s = c.createStatement(); ResultSet rs = s.executeQuery(count_sql); while (rs.next()) { count = rs.getInt("cnt"); } } catch (Exception e) { logger.error(e.getMessage(), e); } int iter = count / 200000; logger.info("Breaking into " + iter + " iterations"); for (int i = 0; i <= iter; i++) { long iterStart = System.currentTimeMillis(); // updateBbox(); updateArea(fid); logger.info("iteration " + i + " completed after " + (System.currentTimeMillis() - iterStart) + "ms"); logger.info("total time taken is " + (System.currentTimeMillis() - start) + "ms"); } }
From source file:bankconsoleapp.console.Main.java
/** * @param args the command line arguments *//*from www .j a v a2s . c om*/ public static void main(String[] args) { //Injecting applicationContext to main ApplicationContext context = new ClassPathXmlApplicationContext("bankconsoleapp/applicationContext.xml"); EmployeeService eS = context.getBean("EmployeeService", EmployeeService.class); CustomerService cS = context.getBean("CustomerService", CustomerService.class); SavingService sS = context.getBean("SavingService", SavingService.class); String userName, pass; Scanner in = new Scanner(System.in); boolean user = false; boolean savingRedo = false; do { System.out.println("Enter Employee ID:"); userName = in.nextLine(); for (Employee emp : eS.getAllEmp()) { if (userName.equals(emp.geteID())) { System.out.println("Password:"); pass = in.nextLine(); for (Employee em : eS.getAllEmp()) { if (pass.equals(em.getPassword())) { user = true; } } } } } while (!user); long start = System.currentTimeMillis(); long end = start + 60 * 1000; // 60 seconds * 1000 ms/sec int operation = 0; int userChoice; boolean quit = false; do { System.out.println("ACME Bank Saving System:"); System.out.println("------------------------"); System.out.println("1. Create Customer & Saving Account"); System.out.println("2. Deposit Money"); System.out.println("3. Withdraw Money"); System.out.println("4. View Balance"); System.out.println("5. Quit"); System.out.print("Operation count: " + operation + "(Shut down at 5)"); userChoice = in.nextInt(); switch (userChoice) { case 1: //create customer, then saving account regard to existing customer( maximum 2 SA per Customer) System.out.println("Create Customer :"); String FirstN, LastN, DoB, accNum, answer; Scanner sc = new Scanner(System.in); Customer c = new Customer(); int saID = 0; System.out.println("Enter First Name:"); FirstN = sc.nextLine(); c.setFname(FirstN); System.out.println("Enter Last Name:"); LastN = sc.nextLine(); c.setLname(LastN); System.out.println("Enter Date of Birth:"); DoB = sc.nextLine(); c.setDoB(DoB); do { System.out.println("Creating saving acount, Enter Account Number:"); accNum = sc.nextLine(); c.setSA(accNum); c.setSavingAccounts(c.getSA()); saID++; System.out.println("Create another SA? Y/N?"); answer = sc.nextLine(); if (answer.equals("n")) { savingRedo = true; } if (saID == 2) { System.out.println("Maximum Saving account reached!"); } } while (!savingRedo && saID != 2); cS.createCustomer(c); operation++; break; case 2: // deposit String acNum; int amt; Scanner sc1 = new Scanner(System.in); System.out.println("Enter Saving Account number u wish to do deposit."); acNum = sc1.nextLine(); System.out.println("Enter amount :"); amt = sc1.nextInt(); sS.deposit(acNum, amt); operation++; break; case 3: String acNums; int amts; Scanner sc2 = new Scanner(System.in); System.out.println("Enter Saving Account number u wish to do withdraw."); acNums = sc2.nextLine(); System.out.println("Enter amount :"); amts = sc2.nextInt(); sS.withdraw(acNums, amts); operation++; break; case 4: // view System.out.println("Saving Account Balance:"); System.out.println(sS.getAllSA()); operation++; break; case 5: quit = true; break; default: System.out.println("Wrong choice."); break; } System.out.println(); if (operation == 5) { System.out.println("5 operation reached, System shutdown."); } if (System.currentTimeMillis() > end) { System.out.println("Session Expired."); } } while (!quit && operation != 5 && System.currentTimeMillis() < end); System.out.println("Bye!"); }
From source file:com.interacciones.mxcashmarketdata.driver.util.AppropriateFormat.java
public static void main(String[] args) throws Throwable { init(args);// ww w . j a va 2 s. co m long time = System.currentTimeMillis(); //for (;;) { try { //read file = new File(source); is = new FileInputStream(file); isr = new InputStreamReader(is); br = new BufferedReader(isr); //write filewrite = new File(destination); fos = new FileOutputStream(filewrite); bos = new BufferedOutputStream(fos); int data = 0; int count = 0; StringBuffer message = new StringBuffer(); while (data != -1) { data = br.read(); message.append((char) data); count++; if (data == 10) { transform(message); count = 0; message.delete(INIT_ASCII, message.length()); } } } catch (Exception e) { LOGGER.error("Warning " + e.getMessage()); e.printStackTrace(); } finally { close(); } //} time = System.currentTimeMillis() - time; LOGGER.info("Time " + time); }