Skip to content

Commit

Permalink
170: Switch to running for a duration rather than a fixed number of i…
Browse files Browse the repository at this point in the history
…terations.
  • Loading branch information
kurtkilpela committed Jan 30, 2025
1 parent d964890 commit 9c4d102
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ Class {
#package : 'RemoteServiceReplication-Test'
}

{ #category : 'accessing' }
RsrSocketStressTest class >> defaultTimeLimit [
"These tests take longer over a Socket"

^120 seconds
]

{ #category : 'testing' }
RsrSocketStressTest class >> isAbstract [

Expand Down
32 changes: 20 additions & 12 deletions src/RemoteServiceReplication-Test/RsrStressTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Class {
{ #category : 'accessing' }
RsrStressTest class >> defaultTimeLimit [

^30 seconds
^Duration seconds: 30
]

{ #category : 'testing' }
Expand Down Expand Up @@ -44,6 +44,12 @@ RsrStressTest >> concurrentlyRun: aBlock [
self deny: anyCurtailed
]

{ #category : 'accessing' }
RsrStressTest >> defaultTestDuration [

^self class defaultTimeLimit / 2
]

{ #category : 'initialize/release' }
RsrStressTest >> initializeServices [

Expand All @@ -63,19 +69,25 @@ RsrStressTest >> numThreads [
{ #category : 'running-utilities' }
RsrStressTest >> repeatedlyRun: aBlock [

self repetitions timesRepeat: aBlock
| endTime |
endTime := DateAndTime now + self defaultTestDuration.
self
repeatedlyRun: aBlock
until: endTime
]

{ #category : 'running-utilities' }
RsrStressTest >> repeatedlySend: anObject [
RsrStressTest >> repeatedlyRun: aBlock
until: endTime [

self repeatedlyRun: [self send: anObject]
[DateAndTime now < endTime]
whileTrue: [aBlock value]
]

{ #category : 'accessing' }
RsrStressTest >> repetitions [
{ #category : 'running-utilities' }
RsrStressTest >> repeatedlySend: anObject [

^1000
self repeatedlyRun: [self send: anObject]
]

{ #category : 'running-utilities' }
Expand Down Expand Up @@ -109,11 +121,7 @@ RsrStressTest >> tearDown [
{ #category : 'running' }
RsrStressTest >> test10MBytes [

| bytes |
bytes := ByteArray new: 1024 * 1024 * 10.
1
to: 10
do: [:i | self send: bytes]
self repeatedlySend: (ByteArray new: 1024 * 1024 * 10)
]

{ #category : 'running' }
Expand Down

0 comments on commit 9c4d102

Please sign in to comment.