Skip to content

Commit e5071c5

Browse files
author
Bruce Eckel
committed
Name and path changes to help track down {CompileTimeError} issue
1 parent b947d10 commit e5071c5

17 files changed

+217
-214
lines changed

arrays/Prefix1.java renamed to arrays/ParallelPrefix1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// arrays/Prefix1.java
1+
// arrays/ParallelPrefix1.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
import java.util.*;
66
import onjava.*;
77
import static onjava.ArrayShow.*;
88

9-
public class Prefix1 {
9+
public class ParallelPrefix1 {
1010
public static void main(String[] args) {
1111
int[] nums = new Count.int_().array(10);
1212
show(nums);

arrays/Prefix2.java renamed to arrays/ParallelPrefix2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// arrays/Prefix2.java
1+
// arrays/ParallelPrefix2.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
import java.util.*;
66
import onjava.*;
77
import static onjava.ArrayShow.*;
88

9-
public class Prefix2 {
9+
public class ParallelPrefix2 {
1010
public static void main(String[] args) {
1111
String[] strings = new Rand.String(1).array(8);
1212
show(strings);

arrays/ParallelPrefix.java renamed to arrays/ParallelPrefix3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// arrays/ParallelPrefix.java
1+
// arrays/ParallelPrefix3.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
import java.util.*;
66

7-
public class ParallelPrefix {
7+
public class ParallelPrefix3 {
88
static final int SIZE = 10_000_000;
99
public static void main(String[] args) {
1010
long[] nums = new long[SIZE];

arrays/ParallelSort.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

arrays/PythonLists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
print(aSlice) # [3, 4]
1515

1616
class MyList(list): # Inherit from list
17-
# Define a method, 'this' pointer is explicit:
17+
# Define a method; 'this' pointer is explicit:
1818
def getReversed(self):
1919
reversed = self[:] # Copy list using slices
2020
reversed.reverse() # Built-in list method

arrays/jmh/ParallelSort.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// arrays/jmh/ParallelSort.java
2+
// (c)2016 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+
package arrays.jmh;
6+
import java.util.*;
7+
import onjava.*;
8+
import org.openjdk.jmh.annotations.*;
9+
10+
@State(Scope.Thread)
11+
public class ParallelSort {
12+
private long[] la;
13+
@Setup
14+
public void setup() {
15+
la = new Rand.long_().array(100_000);
16+
}
17+
@Benchmark
18+
public void sort() {
19+
Arrays.sort(la);
20+
}
21+
@Benchmark
22+
public void parallelSort() {
23+
Arrays.parallelSort(la);
24+
}
25+
}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ subprojects {
229229

230230
// Exclude java sources that will not compile
231231
if (tags.compileTimeError) {
232+
println ">>> Excluding " + file.name
232233
sourceSets.main.java.excludes.add(file.name)
233234
} else {
234235
JavaExec javaTask = null

verifying/BadMicroBenchmark.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
import java.util.*;
6-
import static onjava.TimeIt.*;
76

87
public class BadMicroBenchmark {
98
static final int SIZE = 20_000_000;
109
public static void main(String[] args) {
1110
long[] la = new long[SIZE];
1211
System.out.print("setAll: ");
13-
timeIt(() -> Arrays.setAll(la, n -> n));
12+
Time.it(() -> Arrays.setAll(la, n -> n));
1413
System.out.print("parallelSetAll: ");
15-
timeIt(() -> Arrays.parallelSetAll(la, n -> n));
14+
Time.it(() -> Arrays.parallelSetAll(la, n -> n));
1615
}
1716
}
1817
/* Output:

verifying/BadMicroBenchmark2.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Reversing the test order
66
import java.util.*;
7-
import static onjava.TimeIt.*;
87

98
public class BadMicroBenchmark2 {
109
static final int SIZE = 20_000_000;
1110
public static void main(String[] args) {
1211
long[] la = new long[SIZE];
1312
System.out.print("parallelSetAll: ");
14-
timeIt(() -> Arrays.parallelSetAll(la, n -> n));
13+
Time.it(() -> Arrays.parallelSetAll(la, n -> n));
1514
System.out.print("setAll: ");
16-
timeIt(() -> Arrays.setAll(la, n -> n));
15+
Time.it(() -> Arrays.setAll(la, n -> n));
1716
}
1817
}
1918
/* Output:

verifying/BadMicroBenchmark3.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Relying on a common resource
66
import java.util.*;
7-
import static onjava.TimeIt.*;
87

98
public class BadMicroBenchmark3 {
109
static final int SIZE = 20_000_000;
1110
public static void main(String[] args) {
1211
long[] la = new long[SIZE];
1312
Random r = new Random();
1413
System.out.print("parallelSetAll: ");
15-
timeIt(() ->
14+
Time.it(() ->
1615
Arrays.parallelSetAll(la, n -> r.nextLong()));
1716
System.out.print("setAll: ");
18-
timeIt(() ->
17+
Time.it(() ->
1918
Arrays.setAll(la, n -> r.nextLong()));
2019
SplittableRandom sr = new SplittableRandom();
2120
System.out.print("parallelSetAll: ");
22-
timeIt(() ->
21+
Time.it(() ->
2322
Arrays.parallelSetAll(la, n -> sr.nextLong()));
2423
System.out.print("setAll: ");
25-
timeIt(() ->
24+
Time.it(() ->
2625
Arrays.setAll(la, n -> sr.nextLong()));
2726
}
2827
}

0 commit comments

Comments
 (0)