Skip to content

Commit 2fb3e20

Browse files
committed
Minor changes
1 parent c49521f commit 2fb3e20

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/labs/sem1/lab10/Main.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public static void main(String[] args) {
1010
SynchroStackFast.class
1111
};
1212

13-
int threadsPerMethod = 2; // threads per method
14-
int itersPerMethod = 5; // iterations per method
13+
int threadsPerMethod = 24; // threads per method
14+
int itersPerMethod = 1000; // iterations per method
1515

1616
// logs file path
1717
String logsPath = "src/labs/sem1/lab10/results/%s.csv";
@@ -46,12 +46,12 @@ public static void main(String[] args) {
4646
}
4747
},
4848
() -> { // equals (read operation, light)
49-
for (int i = 0; i < itersPerMethod; i++) {
49+
for (int i = 0; i < itersPerMethod * 20; i++) {
5050
stack.equals(stack);
5151
}
5252
},
5353
() -> { // toString (read operation, heavy)
54-
for (int i = 0; i < itersPerMethod; i++) {
54+
for (int i = 0; i < itersPerMethod / 5; i++) {
5555
stack.toString();
5656
}
5757
}
@@ -106,3 +106,10 @@ public static void main(String[] args) {
106106
}
107107
}
108108
}
109+
110+
// example output:
111+
112+
// Benchmarking: Stack - took 669 ms
113+
// Benchmarking: DebugStack - took 3725 ms
114+
// Benchmarking: SynchroStack - took 3845 ms
115+
// Benchmarking: SynchroStackFast - took 2180 ms

src/labs/sem1/lab10/SynchroStack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// с этим классом одновременно может работать один поток (для всех методов)
44

5-
public class SynchroStack extends DebugStack {
5+
public class SynchroStack extends Stack {
66
// change this to extends DebugStack / Stack to enable / disable debug
77

88
public synchronized void push(int i) {

src/labs/sem1/lab10/SynchroStackFast.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// (push и pop) и несколько читающих (equals и toString)
55
// для этого есть два объекта-монитора: для записи и для чтения
66

7-
public class SynchroStackFast extends DebugStack {
7+
public class SynchroStackFast extends Stack {
88
// change this to extends DebugStack / Stack to enable / disable debug
99

1010
Object readLock = new Object();

0 commit comments

Comments
 (0)