timing

How to program a real-time accurate audio sequencer on the iphone?

。_饼干妹妹 提交于 2019-12-04 07:35:19
问题 I want to program a simple audio sequencer on the iphone but I can't get accurate timing. The last days I tried all possible audio techniques on the iphone, starting from AudioServicesPlaySystemSound and AVAudioPlayer and OpenAL to AudioQueues. In my last attempt I tried the CocosDenshion sound engine which uses openAL and allows to load sounds into multiple buffers and then play them whenever needed. Here is the basic code: init: int channelGroups[1]; channelGroups[0] = 8; soundEngine = [

How to calculate the execution time in C?

天涯浪子 提交于 2019-12-04 07:00:56
问题 How can I calculate the execution time in the following code: #include <stdio.h> /* Core input/output operations */ #include <stdlib.h> /* Conversions, random numbers, memory allocation, etc. */ #include <math.h> /* Common mathematical functions */ #include <time.h> /* Converting between various date/time formats */ #include <sys/time.h> #define PI 3.1415926535 /* Known vaue of PI */ #define NDARTS 128 /* Number of darts thrown */ double pseudo_random(double a, double b) { double r; /* Random

Is the timer resolution of the System.Diagnostics.Stopwatch class stable?

岁酱吖の 提交于 2019-12-04 05:51:00
问题 .Net has support for high resolution timing using the System.Diagnostics.Stopwatch class. I understand that the specific resolution that this class uses differs depending on the underlying hardware and can be obtained via the static property Stopwatch.Frequency . This frequency appears to be related to CPU frequency and Stopwatch reads this value and stores it in a static class variable within a static initializer/constructor. Hence I'm now wondering if this class will report incorrect

How to do correct timing of Android RenderScript code on Nvidia Shield

匆匆过客 提交于 2019-12-04 03:26:48
问题 I have implemented a small CNN in RenderScript and want to profile the performance on different hardware. On my Nexus 7 the times make sense, but on the NVIDIA Shield they do not. The CNN (LeNet) is implemented in 9 layers residing in a queue, computation is performed in sequence. Each layer is timed individually. Here is an example: conv1 pool1 conv2 pool2 resh1 ip1 relu1 ip2 softmax nexus7 11.177 7.813 13.357 8.367 8.097 2.1 0.326 1.557 2.667 shield 13.219 1.024 1.567 1.081 0.988 14.588 13

dynamic module creation [duplicate]

泪湿孤枕 提交于 2019-12-04 02:18:55
This question already has an answer here: Dynamically importing Python module 2 answers I'd like to dynamically create a module from a dictionary, and I'm wondering if adding an element to sys.modules is really the best way to do this. EG context = { a: 1, b: 2 } import types test_context_module = types.ModuleType('TestContext', 'Module created to provide a context for tests') test_context_module.__dict__.update(context) import sys sys.modules['TestContext'] = test_context_module My immediate goal in this regard is to be able to provide a context for timing test execution: import timeit timeit

Measuring execution time of a call to system() in C++

天涯浪子 提交于 2019-12-04 01:36:53
问题 I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does not seem to work for calls to system(). I imagine this is because the execution jumps out of the current process. clock_t begin=clock(); system(something); clock_t end=clock(); cout<<"Execution time: "<<diffclock(end,begin)<<" s."<<endl; Then double diffclock(clock_t clock1,clock_t clock2) { double diffticks=clock1-clock2; double diffms=(diffticks)/(CLOCKS_PER

Mathematica execution-time bug: symbol names

丶灬走出姿态 提交于 2019-12-04 00:01:59
There is a strange bug that has been in Mathematica for years, at least since version 5.1, and persisting through version 7. Module[{f, L}, L = f[]; Do[L = f[L, i], {i, 10^4}]] // Timing {0.015, Null} Module[{weirdness, L}, L = weirdness[]; Do[L = weirdness[L, i], {i, 10^4}]] // Timing {2.266, Null} What causes this? Is it a hashing problem? Is it fixed in Version 8? Is there a way to know what symbol names cause a slowdown, other than testing? Daniel Lichtblau What causes this? Is it a hashing problem? Yes, more or less. Is it fixed in Version 8? Yes (also more or less). That is to say, it is

Why does GetThreadTimes return

我们两清 提交于 2019-12-03 17:28:42
I'm attempting to measure the time spent in a thread for progress reporting purposes, but I'm getting very strange results from from the GetThreadTimes system call. Given the following program (compiled in VS 2013, targeting .NET 4.5): using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; namespace ThreadTimingTest { class Program { static Stopwatch _wallClockTimer; static System.Timers.Timer _timer = new System.Timers.Timer(); private static Thread _thread; private static IntPtr _threadHandle; static void Main(string[] args) { _timer = new

Prevent context-switching in timed section of code (or measure then subtract time not actually spent in thread)

你。 提交于 2019-12-03 14:22:22
I have a multi-threaded application, and in a certain section of code I use a Stopwatch to measure the time of an operation: MatchCollection matches = regex.Matches(text); //lazy evaluation Int32 matchCount; //inside this bracket program should not context switch { //start timer MyStopwatch matchDuration = MyStopwatch.StartNew(); //actually evaluate regex matchCount = matches.Count; //adds the time regex took to a list durations.AddDuration(matchDuration.Stop()); } Now, the problem is if the program switches control to another thread somewhere else while the stopwatch is started, then the

Precisely measure execution time of code in thread (C#)

百般思念 提交于 2019-12-03 12:30:24
I'm trying to measure the execution time of some bits of code as accurately as possible on a number of threads, taking context switching and thread downtime into account. The application is implemented in C# (VS 2008). Example: public void ThreadFunc () { // Some code here // Critical block #1 begins here long lTimestamp1 = Stopwatch.GetTimestamp (); CallComplex3rdPartyFunc (); // A long lTimestamp2 = Stopwatch.GetTimestamp (); // Critical block #1 ends here // Some code here // Critical block #2 begins here long lTimestamp3 = Stopwatch.GetTimestamp (); CallOtherComplex3rdPartyFunc (); // B