Added some useful outputs
This commit is contained in:
@@ -3,3 +3,4 @@
|
|||||||
/consumer_keys.txt
|
/consumer_keys.txt
|
||||||
/info.txt
|
/info.txt
|
||||||
/.classpath
|
/.classpath
|
||||||
|
/primedate.jar
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.TimerTask;
|
|||||||
*/
|
*/
|
||||||
public abstract class MainProcess {
|
public abstract class MainProcess {
|
||||||
|
|
||||||
|
private final static String VERSION = "v1.1";
|
||||||
|
|
||||||
private final static SimpleDateFormat date2num = new SimpleDateFormat("yyyyMMddHHmm");
|
private final static SimpleDateFormat date2num = new SimpleDateFormat("yyyyMMddHHmm");
|
||||||
private final static SimpleDateFormat sdf = new SimpleDateFormat("MMMM d, yyyy 'at' HH:mm", Locale.ENGLISH);
|
private final static SimpleDateFormat sdf = new SimpleDateFormat("MMMM d, yyyy 'at' HH:mm", Locale.ENGLISH);
|
||||||
private final static NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
|
private final static NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
|
||||||
@@ -36,12 +38,17 @@ public abstract class MainProcess {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
System.out.println(String.format("PrimeDate %s%n%s",VERSION,Calendar.getInstance().getTime()));
|
||||||
|
|
||||||
if(args.length < 1) {
|
if(args.length < 1) {
|
||||||
System.out.println("Argument 1 must be a file containing customer keys");
|
System.out.println("Argument 1 must be a file containing customer keys");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TwitterClient.setUpTwitter(args[0])) {
|
if(TwitterClient.setUpTwitter(args[0])) {
|
||||||
|
|
||||||
|
PrimeCalculator.computeList();
|
||||||
|
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package fr.klemek.primedate;
|
package fr.klemek.primedate;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate and check prime numbers
|
* Calculate and check prime numbers
|
||||||
|
*
|
||||||
* @author Kleme
|
* @author Kleme
|
||||||
*/
|
*/
|
||||||
public abstract class PrimeCalculator {
|
public abstract class PrimeCalculator {
|
||||||
@@ -18,6 +21,7 @@ public abstract class PrimeCalculator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get stored bit for number i
|
* Get stored bit for number i
|
||||||
|
*
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -29,6 +33,7 @@ public abstract class PrimeCalculator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set stored bit for number i
|
* Set stored bit for number i
|
||||||
|
*
|
||||||
* @param i
|
* @param i
|
||||||
*/
|
*/
|
||||||
private static void setBit(long i) {
|
private static void setBit(long i) {
|
||||||
@@ -41,7 +46,9 @@ public abstract class PrimeCalculator {
|
|||||||
/**
|
/**
|
||||||
* Computes first million numbers, (takes ~25 ms)
|
* Computes first million numbers, (takes ~25 ms)
|
||||||
*/
|
*/
|
||||||
private static void computeList() {
|
public static void computeList() {
|
||||||
|
Arrays.fill(primes, (byte) 0);
|
||||||
|
long t0 = System.currentTimeMillis();
|
||||||
for (long i = 3; i < SQRT_MAX; i += 2)
|
for (long i = 3; i < SQRT_MAX; i += 2)
|
||||||
if (!getBit(i)) {
|
if (!getBit(i)) {
|
||||||
long j = (i * i);
|
long j = (i * i);
|
||||||
@@ -51,10 +58,13 @@ public abstract class PrimeCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
computed = true;
|
computed = true;
|
||||||
|
System.out.println(
|
||||||
|
String.format("Calculated %d KB of primes in %d ms", MEMORY_SIZE / 1000, System.currentTimeMillis() - t0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next prime stored
|
* Next prime stored
|
||||||
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -67,6 +77,7 @@ public abstract class PrimeCalculator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a number is prime by calculating its block
|
* Check if a number is prime by calculating its block
|
||||||
|
*
|
||||||
* @param number
|
* @param number
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ public abstract class TwitterClient {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Successfuly connected to twitter");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user