Skip to content

Commit

Permalink
added TimeInterval to func monkeyAround()
Browse files Browse the repository at this point in the history
This doesn’t remove the infinite running of monkeyAround() but simply adds the ability to run swiftMonkey tests based on a specific amount of time.

Thanks to mohamede1945 for raising this issue and  dwaynecoussement for answering my question about this improvement 🙌
  • Loading branch information
Graeme Rycyk committed Oct 11, 2017
1 parent 5436e7e commit 3adb653
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions SwiftMonkey/Monkey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ public class Monkey {
}
}

/// Generate random events forever, or until the app crashes.
public func monkeyAround() {
while true {
/// Generate random events or fixed-interval events based on a specific duration or infinitely
public func monkeyAround(forDuration duration: TimeInterval) {
let monkeyTestingTime = Date().timeIntervalSince1970
repeat {
actRandomly()
actRegularly()
}
} while ((Date().timeIntervalSince1970 - monkeyTestingTime) < duration)
}

/// Generate one random event.
Expand Down

0 comments on commit 3adb653

Please sign in to comment.