1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
|
module Events.TestEvents (testTrace)
where
import GHC.RTS.Events
import Data.Word
-------------------------------------------------------------------------------
testTrace :: String -> EventLog
testTrace name = eventLog (test name)
-------------------------------------------------------------------------------
eventLog :: [Event] -> EventLog
eventLog events =
let specBy1000 e@EventBlock{} =
e{end_time = end_time e * 1000,
block_events = map eBy1000 (block_events e)}
specBy1000 e = e
eBy1000 ev = ev{time = time ev * 1000,
spec = specBy1000 (spec ev)}
eventsBy = map eBy1000 events
in EventLog (Header testEventTypes) (Data eventsBy)
-------------------------------------------------------------------------------
create :: Word16
create = 0
-------------------------------------------------------------------------------
runThread :: Word16
runThread = 1
-------------------------------------------------------------------------------
stop :: Word16
stop = 2
-------------------------------------------------------------------------------
runnable :: Word16
runnable = 3
-------------------------------------------------------------------------------
migrate :: Word16
migrate = 4
-------------------------------------------------------------------------------
runSpark :: Word16
runSpark = 5
-------------------------------------------------------------------------------
stealSpark :: Word16
stealSpark = 6
-------------------------------------------------------------------------------
shutdown :: Word16
shutdown = 7
-------------------------------------------------------------------------------
wakeup :: Word16
wakeup = 8
-------------------------------------------------------------------------------
startGC :: Word16
startGC = 9
------------------------------------------------------------------------------
finishGC :: Word16
finishGC = 10
------------------------------------------------------------------------------
reqSeqGC :: Word16
reqSeqGC = 11
------------------------------------------------------------------------------
reqParGC :: Word16
reqParGC = 12
------------------------------------------------------------------------------
createSparkThread :: Word16
createSparkThread = 15
------------------------------------------------------------------------------
logMessage :: Word16
logMessage = 16
------------------------------------------------------------------------------
startup :: Word16
startup = 17
------------------------------------------------------------------------------
blockMarker :: Word16
blockMarker = 18
------------------------------------------------------------------------------
testEventTypes :: [EventType]
testEventTypes
= [EventType create "Create thread" (Just 8),
EventType runThread "Run thread" (Just 8),
EventType stop "Stop thread" (Just 10),
EventType runnable "Thread runnable" (Just 8),
EventType migrate "Migrate thread" (Just 10),
EventType runSpark "Run spark" (Just 8),
EventType stealSpark "Steal spark" (Just 10),
EventType shutdown "Shutdown" (Just 0),
EventType wakeup "Wakeup thread" (Just 10),
EventType startGC "Start GC" (Just 0),
EventType finishGC "Finish GC" (Just 0),
EventType reqSeqGC "Request sequetial GC" (Just 0),
EventType reqParGC "Reqpargc parallel GC" (Just 0),
EventType createSparkThread "Create spark thread" (Just 8),
EventType logMessage "Log message" Nothing,
EventType startup "Startup" (Just 0),
EventType blockMarker "Block marker" (Just 14)
]
-------------------------------------------------------------------------------
test :: String -> [Event]
-------------------------------------------------------------------------------
test "empty0"
= [
Event 0 (Startup 1)
]
-------------------------------------------------------------------------------
test "empty1"
= [
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000 0 []
]
-------------------------------------------------------------------------------
test "test0"
= [
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000 0 [
Event 4000000 Shutdown
]
]
-------------------------------------------------------------------------------
test "small"
= [
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000 0 [
Event 1000000 (CreateThread 1),
Event 2000000 (RunThread 1),
Event 3000000 (StopThread 1 ThreadFinished),
Event 4000000 (Shutdown)
]
]
-------------------------------------------------------------------------------
test "tick"
= [-- A thread from 2s to 3s
Event 0 (Startup 3),
Event 0 $ EventBlock 4000000000 0 [
Event 1000000000 (CreateThread 1),
Event 2000000000 (RunThread 1),
Event 3000000000 (StopThread 1 ThreadFinished),
Event 4000000000 (Shutdown)
],
-- A thread from 0.2ms to 0.3ms
Event 0 $ EventBlock 4000000000 1 [
Event 1000000 (CreateThread 2),
Event 2000000 (RunThread 2),
Event 3000000 (StopThread 2 ThreadFinished),
Event 4000000 (Shutdown)
],
-- A thread from 0.2us to 0.3us
Event 0 $ EventBlock 4000000000 2 [
Event 1000 (CreateThread 3),
Event 2000 (RunThread 3),
Event 3000 (StopThread 3 ThreadFinished),
Event 4000 (Shutdown)
]
]
-------------------------------------------------------------------------------
test "tick2"
= [-- A thread create but no run
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000000 0 [
Event 1000000000 (CreateThread 1),
Event 4000000000 (Shutdown)
]
]
-------------------------------------------------------------------------------
test "tick3"
= [-- A thread from 2s to 3s
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000000 0 [
Event 1000000000 (CreateThread 1),
Event 2000000000 (RunThread 1),
Event 3000000000 (StopThread 1 ThreadFinished),
Event 4000000000 (Shutdown)
]
]
-------------------------------------------------------------------------------
test "tick4"
= [-- A test for scale values close to 1.0
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000000 0 [
Event 100 (CreateThread 1),
Event 200 (RunThread 1),
Event 300 (StopThread 1 ThreadFinished),
Event 400 (Shutdown)
]
]
-------------------------------------------------------------------------------
test "tick5"
= [-- A thread from 2s to 3s
Event 0 (Startup 1),
Event 0 $ EventBlock 4000000000 0 [
Event 1000000000 (CreateThread 1),
Event 2000000000 (RunThread 1),
Event 3000000000 (StopThread 1 ThreadFinished),
Event 4000000000 (Shutdown)
]
]
-------------------------------------------------------------------------------
-- A long tick run to check small and large tick labels
test "tick6" = chequered 2 100 10000000
-------------------------------------------------------------------------------
test "overlap"
= [-- A thread from 2s to 3s
Event 0 (Startup 1),
Event 0 $ EventBlock 3000 0 [
Event 1000 (CreateThread 1),
Event 1100 (RunThread 1),
Event 1200 (CreateThread 2),
Event 1300 (StopThread 1 ThreadFinished),
Event 1400 (RunThread 2),
Event 1500 (CreateThread 3),
Event 1500 (CreateThread 4),
Event 1500 (StopThread 2 ThreadFinished),
Event 1600 (RunThread 3),
Event 1600 (CreateThread 5),
Event 1600 (StopThread 3 ThreadFinished),
Event 1700 (RunThread 4),
Event 1700 (CreateThread 6),
Event 1800 (StopThread 4 ThreadFinished),
Event 3000 (Shutdown)
]
]
-------------------------------------------------------------------------------
-- These tests are for chequered patterns to help check for rendering
-- problems and also to help test the performance of scrolling etc.
-- Each line has a fixed frequency of a thread running and then performing GC.
-- Each successive HEC runs thread at half the frequency of the previous HEC.
test "ch1" = chequered 1 100 100000
test "ch2" = chequered 2 100 100000
test "ch3" = chequered 3 100 100000
test "ch4" = chequered 4 100 100000
test "ch5" = chequered 5 100 100000
test "ch6" = chequered 6 100 100000
test "ch7" = chequered 7 100 100000
test "ch8" = chequered 8 100 100000
-------------------------------------------------------------------------------
test _ = []
-------------------------------------------------------------------------------
chequered :: ThreadId -> Timestamp -> Timestamp -> [Event]
chequered numThreads basicDuration runLength
= Event 0 (Startup (fromIntegral numThreads)) :
makeChequered 1 numThreads basicDuration runLength
-------------------------------------------------------------------------------
makeChequered :: ThreadId -> ThreadId -> Timestamp -> Timestamp -> [Event]
makeChequered currentThread numThreads _basicDuration _runLength
| currentThread > numThreads = [] -- All threads rendered
makeChequered currentThread numThreads basicDuration runLength
= Event 0 eventBlock :
makeChequered (currentThread+1) numThreads (2*basicDuration) runLength
where
eventBlock :: EventInfo
eventBlock = EventBlock runLength (fromIntegral (currentThread-1))
(Event 0 (CreateThread currentThread)
: chequeredPattern currentThread 0 basicDuration runLength)
-------------------------------------------------------------------------------
chequeredPattern :: ThreadId -> Timestamp -> Timestamp -> Timestamp -> [Event]
chequeredPattern currentThread currentPos basicDuration runLength
= if currentPos + 2*basicDuration > runLength then
[Event runLength (Shutdown)]
else
[Event currentPos (RunThread currentThread),
Event (currentPos+basicDuration) (StopThread currentThread ThreadYielding),
Event (currentPos+basicDuration) StartGC,
Event (currentPos+2*basicDuration) EndGC
] ++ chequeredPattern currentThread (currentPos+2*basicDuration) basicDuration runLength
-------------------------------------------------------------------------------
|