- Nov 29, 2005
- 2,411
- 0
- 0
Short [ha!] version:
I'm running a simulation (with undetermined "runtime"). I would like to know utilization intervals for some entities (i.e. 2 cycles on, then 3 cycles off, then 1 cycle on, then 5 cycles off, etc). So I'm trying to figure out the best way to store/recreate this.
I was just thinking of a STL vector (since it has dynamic add/resize) of bits. Then at the end, iterating through it and creating "chunks" from that. Then I thought of a vector of intervals itself, since while I won't know a priori how long something will be idle, I will know once it's active, for how long it will be so (i.e. at cycle 6, I'll know it'll be active for 3 cycles, so I could store, say, <6,9> or <6,3> or something). Then after execution, iterate through again and find the gaps (if any). The problem here is that there may be things like <6,9>, <10,12>,<11,15> which in reality is just <6,15>, since there are no gaps and I don't really care about a specific execution. Which I guess isn't a problem, I guess.
So if I do either of those, what's the best way of [hopefully in line] dumping the off intervals? Like, "after 100 cycles, it was inactive for 4, 5, 10, 1 and 1 cycles". Knowing when/where those intervals happened would be nice, but not essential (although in both cases it would seem I'd have this information).
Anyway, I'm kind of anal so something about the above solutions seems inelegant, and I feel like I'm missing something. Any ideas?
I'm running a simulation (with undetermined "runtime"). I would like to know utilization intervals for some entities (i.e. 2 cycles on, then 3 cycles off, then 1 cycle on, then 5 cycles off, etc). So I'm trying to figure out the best way to store/recreate this.
I was just thinking of a STL vector (since it has dynamic add/resize) of bits. Then at the end, iterating through it and creating "chunks" from that. Then I thought of a vector of intervals itself, since while I won't know a priori how long something will be idle, I will know once it's active, for how long it will be so (i.e. at cycle 6, I'll know it'll be active for 3 cycles, so I could store, say, <6,9> or <6,3> or something). Then after execution, iterate through again and find the gaps (if any). The problem here is that there may be things like <6,9>, <10,12>,<11,15> which in reality is just <6,15>, since there are no gaps and I don't really care about a specific execution. Which I guess isn't a problem, I guess.
So if I do either of those, what's the best way of [hopefully in line] dumping the off intervals? Like, "after 100 cycles, it was inactive for 4, 5, 10, 1 and 1 cycles". Knowing when/where those intervals happened would be nice, but not essential (although in both cases it would seem I'd have this information).
Anyway, I'm kind of anal so something about the above solutions seems inelegant, and I feel like I'm missing something. Any ideas?