re: 通过面试再来看我平时的学习~~~ zhb8015 2012-10-15 11:12
楼主总结的不错,相信这样持续的总结下去会收获不少。自己也存在这样的毛病,只有好好梳理了,东西才是自己的。
re: java深浅复制 zhb8015 2012-04-13 15:24
补充一下:
七、性能测试:
测试结果:复制100000 克隆复制是串行化复制的74倍
100000 clone time:47
100000 serial clone time:3500
Multiple is(serial/clone):74
测试单元的代码:
******************
@Test
public void deepCloneVsSerial() throws CloneNotSupportedException, IOException, ClassNotFoundException {
int max = 100000;
String manName = "Robert C. Martin";
int manAge = 40;
int teacherAge = 50;
String teacherName = "T1";
Teacher teacher = new Teacher(teacherName, teacherAge);
Man man = new Man(manName, manAge, teacher);
//begin
long start1 = System.currentTimeMillis();
for (int i = 0; i < max; i++) {
man.clone();
}
long end1 = System.currentTimeMillis();
System.err.println(max + " clone time:" + (end1 - start1));
long start2 = System.currentTimeMillis();
for (int i = 0; i < max; i++) {
man.serialClone();
}
long end2 = System.currentTimeMillis();
System.err.println(max + " serial clone time:" + (end2 - start2));
System.err.println("Multiple is(serial/clone):" + (end2 - start2)/(end1 - start1));
/**
* 100000 clone time:47
100000 serial clone time:3438
Multiple is(serial/clone):73
*/
}
******************
re: 求质数,难以理解的代码,有兴趣可以看一下 zhb8015 2012-04-12 17:52
Robert C. Martin's explation:
/**
* Every multiple in the array has a prime factor that
* is less than or equal to the root of the array size,
* so we don't have to cross of multiples of numbers
* larger than that root.
*/