Do they belong to you? Claim these comments.
Johan
Is this you? Claim Profile »
5 months ago
in Truce: Google and Microsoft join forces for an open white space spectrum on VentureBeat
Since when did Google and Microsoft agree on the definition of "open"? Good luck!
5 months ago
in WhiteHouse.gov takes a page from Twitter’s playbook on VentureBeat
No, he can't... he's limited to 500 characters.
- 2 points
- Jump to »
Anthony Ha
Exactly ... Maybe I'll send them the link to this post.
11 months ago
in Even More Incriminating Evidence in The Foxconn Debacle! on The Linuxologist
Are all of your stories ripped off from Slashdot comments?
1 year ago
in Performance Comparison - C++ / Java / Python / Ruby/ Jython / JRuby / Groovy on /var/log/mind
sorry, I'd forgotten how slow mod operator is. Even faster:
public class Chain
{
private int size;
public Chain(int size)
{
this.size = size;
}
public int kill(int nth)
{
int[] people = new int[size];
for(int i=0;i 1)
{
curCount++;
if (curCount != nth)
{
people[fillPos] = people[curPos];
fillPos++;
}
else curCount = 0;
curPos++;
if (curPos == realSize)
{
realSize -= (curPos - fillPos);
curPos = 0;
fillPos = 0;
}
}
return people[0];
}
public static void main(String[] args)
{
int ITER = 100000;
runTest(ITER);
runTest(ITER);
runTest(ITER);
runTest(ITER);
}
private static void runTest(int ITER)
{
long start = System.nanoTime();
for (int i = 0 ; i ITER ; i++)
{
Chain chain = new Chain(40);
chain.kill(3);
}
long end = System.nanoTime();
System.out.println("Time per iteration = " + ((end - start) / (ITER )) + " nanoseconds.");
}
}
public class Chain
{
private int size;
public Chain(int size)
{
this.size = size;
}
public int kill(int nth)
{
int[] people = new int[size];
for(int i=0;i 1)
{
curCount++;
if (curCount != nth)
{
people[fillPos] = people[curPos];
fillPos++;
}
else curCount = 0;
curPos++;
if (curPos == realSize)
{
realSize -= (curPos - fillPos);
curPos = 0;
fillPos = 0;
}
}
return people[0];
}
public static void main(String[] args)
{
int ITER = 100000;
runTest(ITER);
runTest(ITER);
runTest(ITER);
runTest(ITER);
}
private static void runTest(int ITER)
{
long start = System.nanoTime();
for (int i = 0 ; i ITER ; i++)
{
Chain chain = new Chain(40);
chain.kill(3);
}
long end = System.nanoTime();
System.out.println("Time per iteration = " + ((end - start) / (ITER )) + " nanoseconds.");
}
}
1 year ago
in Performance Comparison - C++ / Java / Python / Ruby/ Jython / JRuby / Groovy on /var/log/mind
I never understood why microbenchmarks are run with bad algorithms. If performance was critical, I would not write the code the way it has been written above. Also, for Java, in performance critical situations, you should run the test multiple times to see how the JIT compilation affects the performance.
Here is the code I would write for this. It works equally well in Java, C or C++.
public class Chain
{
protected static final String versionID = "@(#) $ Id: $ ";
private int size;
public Chain(int size)
{
this.size = size;
}
public int kill(int nth)
{
int[] people = new int[size];
for(int i=0;i 1)
{
curCount++;
if (curCount % nth != 0)
{
people[fillPos] = people[curPos];
fillPos++;
}
curPos++;
if (curPos == realSize)
{
realSize -= (curPos - fillPos);
curPos = 0;
fillPos = 0;
}
}
return people[0];
}
public static void main(String[] args)
{
int ITER = 100000;
runTest(ITER);
runTest(ITER);
runTest(ITER);
runTest(ITER);
}
private static void runTest(int ITER)
{
long start = System.nanoTime();
for (int i = 0 ; i ITER ; i++)
{
Chain chain = new Chain(40);
chain.kill(3);
}
long end = System.nanoTime();
System.out.println("Time per iteration = " + ((end - start) / (ITER )) + " nanoseconds.");
}
}
Here is the code I would write for this. It works equally well in Java, C or C++.
public class Chain
{
protected static final String versionID = "@(#) $ Id: $ ";
private int size;
public Chain(int size)
{
this.size = size;
}
public int kill(int nth)
{
int[] people = new int[size];
for(int i=0;i 1)
{
curCount++;
if (curCount % nth != 0)
{
people[fillPos] = people[curPos];
fillPos++;
}
curPos++;
if (curPos == realSize)
{
realSize -= (curPos - fillPos);
curPos = 0;
fillPos = 0;
}
}
return people[0];
}
public static void main(String[] args)
{
int ITER = 100000;
runTest(ITER);
runTest(ITER);
runTest(ITER);
runTest(ITER);
}
private static void runTest(int ITER)
{
long start = System.nanoTime();
for (int i = 0 ; i ITER ; i++)
{
Chain chain = new Chain(40);
chain.kill(3);
}
long end = System.nanoTime();
System.out.println("Time per iteration = " + ((end - start) / (ITER )) + " nanoseconds.");
}
}
1 year ago
in DreamWorks to Make Live-Action Ghost in the Shell Movie in 3D on /Film
Ah, you didnt see it? i dont get why so many people are ignoring some great anime movies/series :