**2.1 Application**

To effectively put the temporal complexity measure into practice, the program or simulation implementation will need a way to time stamp and data log context switches during execution. An implementation of a discrete event task scheduler such as the public source Degas (Ludwig & Pukite, 2006) provides such an instrumentation facility.

The simplest input stream is a list of events signified by time-stamps, which will serve to capture the *c(t)* signal. The values for *c(t)* can be as simple as delta functions with a value of unity indicating a context switch.

#### **2.2 Computation**

This algorithm needs a FFT routine. The following pseudo-code guides the calculation calling a generic FFT routine named **Fourier8**. This assumes that each line contains the number of events that occur in the time step and is read through standard input. (This is set to read in exactly 2N lines, where N is an order 15 FFT) If sparse input is provided with time stamps then the data must be transferred into a discrete set of lines with either 0 or N events on each line, due to the nature of the discrete time FFT.

Entropic Complexity Measured in Context Switching 357

Note that for a running simulator, if the data is provided continuously through an output port or pipe, then a suitably fast FFT can report a context switching metric in real time. This is useful for diagnostics, for example correlating the detection of errors with high

We evaluated hypothetical systems with 15 concurrent tasks. One system featured asynchronous events. The other system had tasks cyclically scheduled at different periods. The asynchronous system always had higher switching entropy. The context switching metric distinguishes complicated but synchronized architectures from those with complex

For this metric, by computing the entropy of the phase spectrum in addition to the amplitude may help in discriminating between complexity and noise. That would be straightforward to include because right now we discard the phase information. Any stationary signal that shows asymmetry must have some peculiar phase relationships going on. So it might be easier to discount randomness in favour of more complex phase relationships if we were to include both the amplitude spectrum and the phase spectrum in

Another simple alternative that works on the timing alone is the **gzip** program. This looks at the distribution complexity in times and calculates the entropy metric. The usage of this application is trivial. Take the output file, if a sequence of discrete inputs (zeros and number of values), run it through **gzip** and record the size (Benedetto, et al, 2003). Comparisons of two different sequences of identical length will suggest that the less complex program is the

An alternate approach to measuring the temporal complexity involves the application of the multi-scale entropy metric suggested by (Costa, 2005). This differs from the just described context-witching metric in that it measures the complexity of a temporal behaviour or signal over a wide range of fundamental periods. Whereas the single-scale metric works best over a single-decade frequency spectrum scale, a multi-scale metric offers up the possibility of looking at complexities at a variety of time scales, ranging over potentially orders of magnitude. This is definitely useful but it can't be boiled down into a single complexity metric; instead we will need to depict this graphically over what amounts to a logarithmic

The basis for the multi-scale entropy metric is that many real-world behaviours often occur over time scales of varying dynamic ranges. Costa originally applied this to a biomedical application, trying to extract the temporal complexities of cardiac-driven circulatory systems. When such a pulsed cardiac signal is multi-scale, it is actually composed of a fundamental pulse and various arrhythmias, leading to a complicated spectrum of events. The signal actually appears buried amongst competing behavioural periodicities at different

At first glance, we would imagine that a Fourier transform would work well to extract the periods but in fact a typical FFT algorithm actually works best over a limited dynamic range. By expanding the scope to a multi-scale level, Costa showed that this complexity measure has use in a real-world application and we contend that it may also prove useful

**3. Complementary approach – the multi-scale entropy measure** 

time scales and so it becomes that much harder to extract the information.

complexity regimes.

**2.3 Example of use** 

temporal behaviour

the final metric.

frequency scale.

one of the smaller zipped size.

Fig. 4. Pseudo-code algorithm for calculating the context-switching entropy using a library package FFT routine

Note that for a running simulator, if the data is provided continuously through an output port or pipe, then a suitably fast FFT can report a context switching metric in real time. This is useful for diagnostics, for example correlating the detection of errors with high complexity regimes.
