Commit 94c95f90 authored by Aske Simon Christensen's avatar Aske Simon Christensen
Browse files

Print instrument memory usage

parent 366c6cb1
......@@ -87,6 +87,16 @@ executable is optimizing the size and computation time requirements of the
music. The `OidosConvert` program outputs some statistics about the music
which can be used to guide this process:
**Memory**: The memory needed to store precomputed sound for this instrument.
For each tone an instrument is played with, the sound is precomputed at the
length of the longest note played by the instrument. Thus, the memory
requirement is proportional to the product of these 2 factors:
- The number of different tones the instrument is played with
- The longest note played by the instrument
The memory for precomputed sound is reused for every instrument. The maximum
memory used for all instruments is printed at the end.
**Burden**: The total computation time requirements of all tracks using this
instrument. The time requirement is a product of these 4 factors:
- The value of the *modes* parameter
......
......@@ -816,6 +816,8 @@ def printMusicStats(music, ansi):
print "Music length: %d ticks at %0.2f ticks per minute" % (music.length, 60.0 / music.ticklength)
max_memory_mb = 0
max_memory_instr = None
total_burden = 0
ii = None
for ti,tn in enumerate(music.track_order):
......@@ -834,9 +836,15 @@ def printMusicStats(music, ansi):
modes = instr.paramblock[0]
fat = instr.paramblock[1]
longest = float(instr.paramblock[16]) / SAMPLERATE
memory = len(instr.tones) * longest
memory_mb = memory * SAMPLERATE * 16 / 1024 / 1024
if memory_mb > max_memory_mb:
max_memory_mb = memory_mb
max_memory_instr = instr.title
burden = modes * fat * len(instr.tones) * longest
total_burden += burden
print form("H") % instr.title
print " Memory: " + form(" tones X longest = %d X %.3f = B (B %s)") % (len(instr.tones), longest, memory, memory_mb, "MB")
print " Burden: " + form(" modes X fat X tones X longest = %d X %d X %d X %.3f = B") % (modes, fat, len(instr.tones), longest, burden)
tones = ""
for t in instr.tones:
......@@ -871,6 +879,7 @@ def printMusicStats(music, ansi):
seconds = int(round(total_burden / 5000))
print
print "Maximum instrument memory: " + form("B %s (H)") % (max_memory_mb, "MB", max_memory_instr)
print "Total burden: " + form("B (approximately D on a fast %s)") % (total_burden, seconds / 60, seconds % 60, "CPU")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment