mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
Remove naked new[] in: Benchmark
This commit is contained in:
parent
18be1bdad6
commit
ce2e154e89
@ -373,28 +373,29 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
int trials = numEdits;
|
int trials = numEdits;
|
||||||
|
|
||||||
short *small1 = new short[nChunks];
|
using Shorts = ArrayOf < short > ;
|
||||||
short *block = new short[chunkSize];
|
Shorts small1{ nChunks };
|
||||||
|
Shorts block{ chunkSize };
|
||||||
|
|
||||||
Printf(wxT("Preparing...\n"));
|
Printf(wxT("Preparing...\n"));
|
||||||
|
|
||||||
wxTheApp->Yield();
|
wxTheApp->Yield();
|
||||||
FlushPrint();
|
FlushPrint();
|
||||||
|
|
||||||
int i, b, v;
|
int v;
|
||||||
int bad;
|
int bad;
|
||||||
int z;
|
int z;
|
||||||
long elapsed;
|
long elapsed;
|
||||||
wxString tempStr;
|
wxString tempStr;
|
||||||
wxStopWatch timer;
|
wxStopWatch timer;
|
||||||
|
|
||||||
for (i = 0; i < nChunks; i++) {
|
for (size_t i = 0; i < nChunks; i++) {
|
||||||
v = short(rand());
|
v = short(rand());
|
||||||
small1[i] = v;
|
small1[i] = v;
|
||||||
for (b = 0; b < chunkSize; b++)
|
for (size_t b = 0; b < chunkSize; b++)
|
||||||
block[b] = v;
|
block[b] = v;
|
||||||
|
|
||||||
t->Append((samplePtr)block, int16Sample, chunkSize);
|
t->Append((samplePtr)block.get(), int16Sample, chunkSize);
|
||||||
}
|
}
|
||||||
t->Flush();
|
t->Flush();
|
||||||
|
|
||||||
@ -486,10 +487,10 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
bad = 0;
|
bad = 0;
|
||||||
timer.Start();
|
timer.Start();
|
||||||
for (i = 0; i < nChunks; i++) {
|
for (size_t i = 0; i < nChunks; i++) {
|
||||||
v = small1[i];
|
v = small1[i];
|
||||||
t->Get((samplePtr)block, int16Sample, i * chunkSize, chunkSize);
|
t->Get((samplePtr)block.get(), int16Sample, i * chunkSize, chunkSize);
|
||||||
for (b = 0; b < chunkSize; b++)
|
for (size_t b = 0; b < chunkSize; b++)
|
||||||
if (block[b] != v) {
|
if (block[b] != v) {
|
||||||
bad++;
|
bad++;
|
||||||
if (bad < 10)
|
if (bad < 10)
|
||||||
@ -512,10 +513,10 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
for (i = 0; i < nChunks; i++) {
|
for (size_t i = 0; i < nChunks; i++) {
|
||||||
v = small1[i];
|
v = small1[i];
|
||||||
t->Get((samplePtr)block, int16Sample, i * chunkSize, chunkSize);
|
t->Get((samplePtr)block.get(), int16Sample, i * chunkSize, chunkSize);
|
||||||
for (b = 0; b < chunkSize; b++)
|
for (size_t b = 0; b < chunkSize; b++)
|
||||||
if (block[b] != v)
|
if (block[b] != v)
|
||||||
bad++;
|
bad++;
|
||||||
}
|
}
|
||||||
@ -534,8 +535,6 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
|
|||||||
Printf(wxT("TEST FAILED!!!\n"));
|
Printf(wxT("TEST FAILED!!!\n"));
|
||||||
|
|
||||||
success:
|
success:
|
||||||
delete[]small1;
|
|
||||||
delete[]block;
|
|
||||||
|
|
||||||
dd.reset();
|
dd.reset();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user