replace usage of whitelist with allowlist
[LibreOffice.git] / libreofficekit / qa / tilebench / tilebench.cxx
blobf2fbd1752c758ccebea1e5f4aee6f8320196e3d1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <stdio.h>
11 #include <string.h>
12 #include <cmath>
14 #include <vector>
15 #include <atomic>
16 #include <iostream>
17 #include <osl/time.h>
19 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
20 #include <LibreOfficeKit/LibreOfficeKitInit.h>
21 #include <LibreOfficeKit/LibreOfficeKit.hxx>
23 #include <boost/property_tree/json_parser.hpp>
25 using namespace lok;
27 static int help( const char *error = nullptr )
29 if (error)
30 fprintf (stderr, "Error: %s\n\n", error);
31 fprintf( stderr, "Usage: tilebench <absolute-path-to-libreoffice-install> [path to document] [--preinit] <options>\n");
32 fprintf( stderr, "\trenders a selection of small tiles from the document, checksums them and times the process based on options:\n" );
33 fprintf( stderr, "\t--tile\t[max parts|-1] [max tiles|-1]\n" );
34 fprintf( stderr, "\t--dialog\t<.uno:Command>\n" );
35 fprintf( stderr, "\t--join\trun tile joining tests\n" );
36 return 1;
39 static double getTimeNow()
41 TimeValue aValue;
42 osl_getSystemTime(&aValue);
43 return static_cast<double>(aValue.Seconds) +
44 static_cast<double>(aValue.Nanosec) / (1000*1000*1000);
47 static double origin;
49 namespace {
51 struct TimeRecord {
52 const char *mpName;
53 double mfTime;
55 TimeRecord() : mpName(nullptr), mfTime(getTimeNow()) { }
56 explicit TimeRecord(const char *pName) :
57 mpName(pName), mfTime(getTimeNow())
59 fprintf(stderr, "%3.3fs - %s\n", (mfTime - origin), mpName);
65 static std::vector< TimeRecord > aTimes;
67 /// Dump an array (or sub-array) of RGBA or BGRA to an RGB PPM file.
68 static void dumpTile(const char *pNameStem,
69 const int nWidth, const int nHeight,
70 const int mode, const unsigned char* pBufferU,
71 const int nOffX = 0, const int nOffY = 0,
72 int nTotalWidth = -1)
74 if (nTotalWidth < 0)
75 nTotalWidth = nWidth;
77 auto pBuffer = reinterpret_cast<const char *>(pBufferU);
78 static int counter = 0;
79 std::string aName = "/tmp/dump_tile";
80 aName += pNameStem;
81 aName += "_" + std::to_string(counter);
82 aName += ".ppm";
83 #ifndef IOS
84 std::ofstream ofs(aName);
85 #else
86 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
87 NSString *documentsDirectory = [paths objectAtIndex:0];
88 NSString *path = [NSString stringWithFormat:@"%@/dump_tile_%d.ppm", documentsDirectory, counter];
89 std::ofstream ofs([path UTF8String]);
90 std::cerr << "---> Dumping tile\n";
91 #endif
92 counter++;
93 ofs << "P6\n"
94 << nWidth << " "
95 << nHeight << "\n"
96 << 255 << "\n" ;
98 const bool dumpText = false;
100 if (dumpText)
101 fprintf(stderr, "Stream %s - %dx%d:\n", pNameStem, nWidth, nHeight);
103 for (int y = 0; y < nHeight; ++y)
105 const char* row = pBuffer + (y + nOffY) * nTotalWidth * 4 + nOffX * 4;
106 for (int x = 0; x < nWidth; ++x)
108 const char* pixel = row + x * 4;
109 if (mode == LOK_TILEMODE_RGBA)
111 ofs.write(pixel, 3); // Skip alpha
113 else if (mode == LOK_TILEMODE_BGRA)
115 const int alpha = *(pixel + 3);
116 char buf[3];
117 if (alpha == 0)
119 buf[0] = 0;
120 buf[1] = 0;
121 buf[2] = 0;
123 else
125 buf[0] = (*(pixel + 2) * 255 + alpha / 2) / alpha;
126 buf[1] = (*(pixel + 1) * 255 + alpha / 2) / alpha;
127 buf[2] = (*(pixel + 0) * 255 + alpha / 2) / alpha;
130 ofs.write(buf, 3);
132 if (dumpText)
134 int lowResI = (pixel[0] + pixel[1] + pixel[2])/(3*16);
135 fprintf(stderr,"%1x", lowResI);
138 if (dumpText)
139 fprintf(stderr,"\n");
141 ofs.close();
144 static void testTile( Document *pDocument, int max_parts,
145 int max_tiles, bool dump )
147 const int mode = pDocument->getTileMode();
149 aTimes.emplace_back("getparts");
150 const int nOriginalPart = (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT ? 1 : pDocument->getPart());
151 // Writer really has 1 part (the full doc).
152 const int nTotalParts = (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT ? 1 : pDocument->getParts());
153 const int nParts = (max_parts < 0 ? nTotalParts : std::min(max_parts, nTotalParts));
154 aTimes.emplace_back();
156 aTimes.emplace_back("get size of parts");
157 long nWidth = 0;
158 long nHeight = 0;
159 for (int n = 0; n < nParts; ++n)
161 const int nPart = (nOriginalPart + n) % nTotalParts;
162 char* pName = pDocument->getPartName(nPart);
163 pDocument->setPart(nPart);
164 pDocument->getDocumentSize(&nWidth, &nHeight);
165 fprintf (stderr, " '%s' -> %ld, %ld\n", pName, nWidth, nHeight);
166 free (pName);
168 aTimes.emplace_back();
170 // Use realistic dimensions, similar to the Online client.
171 long const nTilePixelWidth = 512;
172 long const nTilePixelHeight = 512;
173 long const nTileTwipWidth = 3840;
174 long const nTileTwipHeight = 3840;
176 // Estimate the maximum tiles based on the number of parts requested, if Writer.
177 if (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT)
178 max_tiles = static_cast<int>(ceil(max_parts * 16128. / nTilePixelHeight) * ceil(static_cast<double>(nWidth) / nTilePixelWidth));
179 fprintf(stderr, "Parts to render: %d, Total Parts: %d, Max parts: %d, Max tiles: %d\n", nParts, nTotalParts, max_parts, max_tiles);
181 std::vector<unsigned char> vBuffer(nTilePixelWidth * nTilePixelHeight * 4);
182 unsigned char* pPixels = vBuffer.data();
184 for (int n = 0; n < nParts; ++n)
186 const int nPart = (nOriginalPart + n) % nTotalParts;
187 char* pName = pDocument->getPartName(nPart);
188 pDocument->setPart(nPart);
189 pDocument->getDocumentSize(&nWidth, &nHeight);
190 fprintf (stderr, "render '%s' -> %ld, %ld\n", pName, nWidth, nHeight);
191 free (pName);
193 if (dump || pDocument->getDocumentType() != LOK_DOCTYPE_TEXT)
195 // whole part; meaningful only for non-writer documents.
196 aTimes.emplace_back("render whole part");
197 pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
198 nWidth/2, 2000, 1000, 1000);
199 aTimes.emplace_back();
200 if (dump)
201 dumpTile("tile", nTilePixelWidth, nTilePixelHeight, mode, pPixels);
204 { // 1:1
205 aTimes.emplace_back("render sub-region at 1:1");
206 // Estimate the maximum tiles based on the number of parts requested, if Writer.
207 int nMaxTiles = max_tiles;
208 int nTiles = 0;
209 for (long nY = 0; nY < nHeight - 1; nY += nTilePixelHeight)
211 for (long nX = 0; nX < nWidth - 1; nX += nTilePixelWidth)
213 if (nMaxTiles >= 0 && nTiles >= nMaxTiles)
215 nY = nHeight;
216 break;
218 pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
219 nX, nY, nTilePixelWidth, nTilePixelHeight);
220 nTiles++;
221 fprintf (stderr, " rendered 1:1 tile %d at %ld, %ld\n",
222 nTiles, nX, nY);
225 aTimes.emplace_back();
228 { // scaled
229 aTimes.emplace_back("render sub-regions at scale");
230 int nMaxTiles = max_tiles;
231 if (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT)
232 nMaxTiles = static_cast<int>(ceil(max_parts * 16128. / nTileTwipHeight) * ceil(static_cast<double>(nWidth) / nTileTwipWidth));
233 int nTiles = 0;
234 for (long nY = 0; nY < nHeight - 1; nY += nTileTwipHeight)
236 for (long nX = 0; nX < nWidth - 1; nX += nTileTwipWidth)
238 if (nMaxTiles >= 0 && nTiles >= nMaxTiles)
240 nY = nHeight;
241 break;
243 pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
244 nX, nY, nTileTwipWidth, nTileTwipHeight);
245 nTiles++;
246 fprintf (stderr, " rendered scaled tile %d at %ld, %ld\n",
247 nTiles, nX, nY);
250 aTimes.emplace_back();
255 static uint32_t fade(uint32_t col)
257 uint8_t a = (col >> 24) & 0xff;
258 uint8_t b = (col >> 16) & 0xff;
259 uint8_t g = (col >> 8) & 0xff;
260 uint8_t r = (col >> 0) & 0xff;
261 uint8_t grey = (r+g+b)/6;
262 return (a<<24) + (grey<<16) + (grey<<8) + grey;
265 static bool sloppyEqual(uint32_t pixA, uint32_t pixB)
267 uint8_t a[4], b[4];
269 a[0] = (pixA >> 24) & 0xff;
270 a[1] = (pixA >> 16) & 0xff;
271 a[2] = (pixA >> 8) & 0xff;
272 a[3] = (pixA >> 0) & 0xff;
274 b[0] = (pixB >> 24) & 0xff;
275 b[1] = (pixB >> 16) & 0xff;
276 b[2] = (pixB >> 8) & 0xff;
277 b[3] = (pixB >> 0) & 0xff;
279 for (int i = 0; i < 4; ++i)
281 int delta = a[i];
282 delta -= b[i];
283 // tolerate small differences
284 if (delta < -4 || delta > 4)
285 return false;
287 return true;
290 // Count and build a picture of any differences into rDiff
291 static int diffTiles( const std::vector<unsigned char> &vBase,
292 long nBaseRowPixelWidth,
293 const std::vector<unsigned char> &vCompare,
294 long nCompareRowPixelWidth,
295 long nTilePixelHeight,
296 long nPosX, long nPosY,
297 std::vector<unsigned char> &rDiff )
299 int nDifferent = 0;
300 const uint32_t *pBase = reinterpret_cast<const uint32_t *>(vBase.data());
301 const uint32_t *pCompare = reinterpret_cast<const uint32_t *>(vCompare.data());
302 uint32_t *pDiff = reinterpret_cast<uint32_t *>(rDiff.data());
303 long left = 0, mid = nCompareRowPixelWidth, right = nCompareRowPixelWidth*2;
304 for (long y = 0; y < nTilePixelHeight; ++y)
306 long nBaseOffset = nBaseRowPixelWidth * (y + nPosY) + nPosX * nCompareRowPixelWidth;
307 long nCompareOffset = nCompareRowPixelWidth * y;
308 long nDiffRowStart = nCompareOffset * 3;
309 for (long x = 0; x < nCompareRowPixelWidth; ++x)
311 pDiff[nDiffRowStart + left + x] = pBase[nBaseOffset + x];
312 pDiff[nDiffRowStart + mid + x] = pCompare[nCompareOffset + x];
313 pDiff[nDiffRowStart + right + x] = fade(pBase[nBaseOffset + x]);
314 if (!sloppyEqual(pBase[nBaseOffset + x], pCompare[nCompareOffset + x]))
316 pDiff[nDiffRowStart + right + x] = 0xffff00ff;
317 if (!nDifferent)
318 fprintf (stderr, "First mismatching pixel at %ld (pixels) into row %ld\n", x, y);
319 nDifferent++;
323 return nDifferent;
326 static std::vector<unsigned char> paintTile( Document *pDocument,
327 long nX, long nY,
328 long const nTilePixelWidth,
329 long const nTilePixelHeight,
330 long const nTileTwipWidth,
331 long const nTileTwipHeight )
333 // long e = 0; // tweak if we suspect an overlap / visibility issue.
334 // pDocument->setClientVisibleArea( nX - e, nY - e, nTileTwipWidth + e, nTileTwipHeight + e );
335 std::vector<unsigned char> vData( nTilePixelWidth * nTilePixelHeight * 4 );
336 pDocument->paintTile( vData.data(), nTilePixelWidth, nTilePixelHeight,
337 nX, nY, nTileTwipWidth, nTileTwipHeight );
338 return vData;
341 static int testJoinsAt( Document *pDocument, long nX, long nY,
342 long const nTilePixelSize,
343 long const nTileTwipSize )
345 const int mode = pDocument->getTileMode();
347 long const nTilePixelWidth = nTilePixelSize;
348 long const nTilePixelHeight = nTilePixelSize;
349 long const nTileTwipWidth = nTileTwipSize;
350 long const nTileTwipHeight = nTileTwipSize;
352 long initPosX = nX * nTileTwipWidth, initPosY = nY * nTileTwipHeight;
354 // Calc has to do significant work on changing zoom ...
355 pDocument->setClientZoom( nTilePixelWidth, nTilePixelHeight,
356 nTileTwipWidth, nTileTwipHeight );
358 // Unfortunately without getting this nothing renders ...
359 std::stringstream aForceHeaders;
360 aForceHeaders << ".uno:ViewRowColumnHeaders?x=" << initPosX << "&y=" << initPosY <<
361 "&width=" << (nTileTwipWidth * 2) << "&height=" << (nTileTwipHeight * 2);
362 std::string cmd = aForceHeaders.str();
363 char* pJSON = pDocument->getCommandValues(cmd.c_str());
364 fprintf(stderr, "command: '%s' values '%s'\n", cmd.c_str(), pJSON);
365 free(pJSON);
367 // Get a base image 4x the size
368 std::vector<unsigned char> vBase(
369 paintTile(pDocument, initPosX, initPosY,
370 nTilePixelWidth * 2, nTilePixelHeight * 2,
371 nTileTwipWidth * 2, nTileTwipHeight * 2));
373 const struct {
374 long X;
375 long Y;
376 } aCompare[] = {
377 { 0, 0 },
378 { 1, 0 },
379 { 0, 1 },
380 { 1, 1 }
383 int nDifferences = 0;
384 // Compare each of the 4x tiles with a sub-tile of the larger image
385 for( auto &rPos : aCompare )
387 std::vector<unsigned char> vCompare(
388 paintTile(pDocument,
389 initPosX + rPos.X * nTileTwipWidth,
390 initPosY + rPos.Y * nTileTwipHeight,
391 nTilePixelWidth, nTilePixelHeight,
392 nTileTwipWidth, nTileTwipHeight));
394 std::vector<unsigned char> vDiff( nTilePixelWidth * 3 * nTilePixelHeight * 4 );
395 int nDiffs = diffTiles( vBase, nTilePixelWidth * 2,
396 vCompare, nTilePixelWidth,
397 nTilePixelHeight,
398 rPos.X, rPos.Y * nTilePixelHeight,
399 vDiff );
400 if ( nDiffs > 0 )
402 fprintf( stderr, " %d differences in sub-tile pixel mismatch at %ld, %ld at offset %ld, %ld (twips) size %ld\n",
403 nDiffs, rPos.X, rPos.Y, initPosX, initPosY,
404 nTileTwipWidth);
405 dumpTile("_base", nTilePixelWidth * 2, nTilePixelHeight * 2,
406 mode, vBase.data());
407 /* dumpTile("_sub", nTilePixelWidth, nTilePixelHeight,
408 mode, vBase.data(),
409 rPos.X*nTilePixelWidth, rPos.Y*nTilePixelHeight,
410 nTilePixelWidth * 2);
411 dumpTile("_compare", nTilePixelWidth, nTilePixelHeight,
412 mode, vCompare.data());*/
413 dumpTile("_diff", nTilePixelWidth * 3, nTilePixelHeight, mode, vDiff.data());
415 nDifferences += nDiffs;
418 return nDifferences;
421 // Check that our tiles join nicely ...
422 static int testJoin( Document *pDocument)
424 // Ignore parts - just the first for now ...
425 long nWidth = 0, nHeight = 0;
426 pDocument->getDocumentSize(&nWidth, &nHeight);
427 fprintf (stderr, "Width is %ld, %ld (twips)\n", nWidth, nHeight);
429 // Use realistic dimensions, similar to the Online client.
430 long const nTilePixelSize = 256;
431 long const nTileTwipSize = 3840;
432 double fZooms[] = {
433 0.5,
434 0.6, 0.7, 0.85,
435 1.0,
436 1.2, 1.5, 1.75,
439 long nFails = 0;
440 std::stringstream results;
442 for( auto z : fZooms )
444 long nBad = 0;
445 long nDifferences = 0;
446 for( long y = 0; y < 8; ++y )
448 for( long x = 0; x < 8; ++x )
450 int nDiffs = testJoinsAt( pDocument, x, y, nTilePixelSize, nTileTwipSize * z );
451 if (nDiffs)
452 nBad++;
453 nDifferences += nDiffs;
456 if (nBad > 0)
457 results << "\tZoom " << z << " bad tiles: " << nBad << " with " << nDifferences << " mismatching pixels\n";
458 nFails += nBad;
461 if (nFails > 0)
462 fprintf( stderr, "Failed %ld joins\n", nFails );
463 else
464 fprintf( stderr, "All joins compared correctly\n" );
466 fprintf(stderr, "%s\n", results.str().c_str());
468 return nFails;
471 static std::atomic<bool> bDialogRendered(false);
472 static std::atomic<int> nDialogId(-1);
474 static void kitCallback(int nType, const char* pPayload, void* pData)
476 Document *pDocument = static_cast<Document *>(pData);
478 if (nType != LOK_CALLBACK_WINDOW)
479 return;
481 std::stringstream aStream(pPayload);
482 boost::property_tree::ptree aRoot;
483 boost::property_tree::read_json(aStream, aRoot);
484 nDialogId = aRoot.get<unsigned>("id");
485 const std::string aAction = aRoot.get<std::string>("action");
487 if (aAction == "created")
489 const std::string aType = aRoot.get<std::string>("type");
490 const std::string aSize = aRoot.get<std::string>("size");
491 int nWidth = atoi(aSize.c_str());
492 int nHeight = 400;
493 const char *pComma = strstr(aSize.c_str(), ", ");
494 if (pComma)
495 nHeight = atoi(pComma + 2);
496 std::cerr << "Size " << aSize << " is " << nWidth << ", " << nHeight << "\n";
498 if (aType == "dialog")
500 aTimes.emplace_back(); // complete wait for dialog
502 unsigned char *pBuffer = new unsigned char[nWidth * nHeight * 4];
504 aTimes.emplace_back("render dialog");
505 pDocument->paintWindow(nDialogId, pBuffer, 0, 0, nWidth, nHeight);
506 dumpTile("dialog", nWidth, nHeight, pDocument->getTileMode(), pBuffer);
507 aTimes.emplace_back();
509 delete[] pBuffer;
511 bDialogRendered = true;
516 static void testDialog( Document *pDocument, const char *uno_cmd )
518 int view = pDocument->createView();
519 pDocument->setView(view);
520 pDocument->registerCallback(kitCallback, pDocument);
522 aTimes.emplace_back("open dialog");
523 pDocument->postUnoCommand(uno_cmd, nullptr, true);
524 aTimes.emplace_back();
526 aTimes.emplace_back("wait for dialog");
527 while (!bDialogRendered)
529 usleep (1000);
532 aTimes.emplace_back("post close dialog");
533 pDocument->postWindow(nDialogId, LOK_WINDOW_CLOSE);
534 aTimes.emplace_back();
536 pDocument->destroyView(view);
539 static void documentCallback(const int type, const char* p, void*)
541 std::cerr << "Document callback " << type << ": " << (p ? p : "(null)") << "\n";
544 // Avoid excessive dbgutil churn.
545 static void ignoreCallback(const int /*type*/, const char* /*p*/, void* /*data*/)
549 int main( int argc, char* argv[] )
551 int arg = 2;
552 origin = getTimeNow();
554 #ifndef IOS
555 // avoid X oddness etc.
556 unsetenv("DISPLAY");
558 if( argc < 4 ||
559 ( argc > 1 && ( !strcmp( argv[1], "--help" ) || !strcmp( argv[1], "-h" ) ) ) )
560 return help();
562 if ( argv[1][0] != '/' )
564 fprintf(stderr, "Absolute path required to libreoffice install\n");
565 return 1;
568 const char *doc_url = argv[arg++];
569 const char *mode = argv[arg++];
571 bool pre_init = false;
572 if (!strcmp(mode, "--preinit"))
574 pre_init = true;
575 mode = argv[arg++];
578 std::string user_url("file:///");
579 user_url.append(argv[1]);
580 user_url.append("../user");
582 if (pre_init)
584 aTimes.emplace_back("pre-initialization");
585 setenv("LOK_ALLOWLIST_LANGUAGES", "en_US", 0);
586 // coverity[tainted_string] - build time test tool
587 lok_preinit(argv[1], user_url.c_str());
588 aTimes.emplace_back();
590 const char *install_path = argv[1];
591 const char *user_profile = user_url.c_str();
592 #else
593 const char *install_path = nullptr;
594 const char *user_profile = nullptr;
595 const char *doc_url = strdup([[[[[NSBundle mainBundle] bundleURL] absoluteString] stringByAppendingString:@"/test.odt"] UTF8String]);
596 const char *mode = "--tile";
597 #endif
599 aTimes.emplace_back("initialization");
600 // coverity[tainted_string] - build time test tool
601 std::unique_ptr<Office> pOffice( lok_cpp_init(install_path, user_profile) );
602 if (pOffice == nullptr)
604 fprintf(stderr, "Failed to initialize Office from %s\n", argv[1]);
605 return 1;
607 aTimes.emplace_back();
608 pOffice->registerCallback(ignoreCallback, nullptr);
610 std::unique_ptr<Document> pDocument;
612 pOffice->setOptionalFeatures(LOK_FEATURE_NO_TILED_ANNOTATIONS);
614 aTimes.emplace_back("load document");
615 if (doc_url != nullptr)
616 pDocument.reset(pOffice->documentLoad(doc_url));
617 aTimes.emplace_back();
619 if (pDocument)
621 pDocument->initializeForRendering("{\".uno:Author\":{\"type\":\"string\",\"value\":\"Local Host #0\"}}");
622 pDocument->registerCallback(documentCallback, nullptr);
623 if (!strcmp(mode, "--tile"))
625 const int max_parts = (argc > arg ? atoi(argv[arg++]) : -1);
626 int max_tiles = (argc > arg ? atoi(argv[arg++]) : -1);
627 const bool dump = true;
629 testTile (pDocument.get(), max_parts, max_tiles, dump);
631 else if (!strcmp(mode, "--join"))
633 return testJoin (pDocument.get());
635 else if (!strcmp (mode, "--dialog"))
637 const char *uno_cmd = argc > arg ? argv[arg++] : nullptr;
638 if (!uno_cmd)
640 switch (pDocument->getDocumentType())
642 case LOK_DOCTYPE_SPREADSHEET:
643 uno_cmd = ".uno:FormatCellDialog";
644 break;
645 case LOK_DOCTYPE_TEXT:
646 case LOK_DOCTYPE_PRESENTATION:
647 case LOK_DOCTYPE_DRAWING:
648 case LOK_DOCTYPE_OTHER:
649 return help("missing argument to --dialog and no default");
652 testDialog (pDocument.get(), uno_cmd);
653 } else
654 return help ("unknown parameter");
657 aTimes.emplace_back("destroy document");
658 pDocument.reset();
659 aTimes.emplace_back();
661 pOffice.reset();
663 double nTotal = 0.0;
664 fprintf (stderr, "profile run:\n");
665 for (size_t i = 0; i < aTimes.size() - 1; i++)
667 const double nDelta = aTimes[i+1].mfTime - aTimes[i].mfTime;
668 fprintf (stderr, " %s - %2.4f(ms)\n", aTimes[i].mpName, nDelta * 1000.0);
669 if (aTimes[i+1].mpName == nullptr)
670 i++; // skip it.
671 nTotal += nDelta;
673 fprintf (stderr, "Total: %2.4f(s)\n", nTotal);
674 return 0;
677 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */