Initial RLE benchmark.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com> Change-Id: I00a7903fe9b10066881b1637f6ae9ad59ff6607b
This commit is contained in:
parent
295fcc2d9c
commit
04b74d5767
2 changed files with 93 additions and 0 deletions
|
@ -164,6 +164,7 @@ noinst_PROGRAMS = clientnb \
|
|||
connect \
|
||||
lokitclient \
|
||||
coolmap \
|
||||
coolbench \
|
||||
coolsocketdump
|
||||
|
||||
if ENABLE_LIBFUZZER
|
||||
|
@ -270,6 +271,14 @@ coolmount_SOURCES = tools/mount.cpp
|
|||
|
||||
coolmap_SOURCES = tools/map.cpp
|
||||
|
||||
coolbench_SOURCES = tools/Benchmark.cpp \
|
||||
common/DummyTraceEventEmitter.cpp \
|
||||
common/Log.cpp \
|
||||
common/StringVector.cpp \
|
||||
common/Util.cpp \
|
||||
common/Simd.cpp
|
||||
coolbench_LDADD = libsimd.a
|
||||
|
||||
coolconvert_SOURCES = tools/Tool.cpp
|
||||
|
||||
coolstress_CPPFLAGS = -DTDOC=\"$(abs_top_srcdir)/test/data\" ${include_paths}
|
||||
|
|
84
tools/Benchmark.cpp
Normal file
84
tools/Benchmark.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* Copyright the Collabora Online contributors.
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
/*
|
||||
* Benchmark various bits of cool code.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <common/Png.hpp>
|
||||
#include <kit/Delta.hpp>
|
||||
|
||||
typedef std::vector<char> Pixmap;
|
||||
|
||||
std::vector<Pixmap> pixmaps;
|
||||
|
||||
class DeltaTests {
|
||||
public:
|
||||
static void rleBitmap(Pixmap &pix)
|
||||
{
|
||||
TileLocation loc = { 0, 0, 0, 0, 0 };
|
||||
DeltaGenerator::DeltaData rleData(
|
||||
1 /*wid*/, reinterpret_cast<unsigned char *>(pix.data()),
|
||||
0, 0, 256, 256, loc, 256, 256);
|
||||
}
|
||||
|
||||
static void timeRLE(const char *description)
|
||||
{
|
||||
std::cout << "Benchmark " << description << "\n";
|
||||
|
||||
int deltas = 0;
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
|
||||
// check we have enough work:
|
||||
int maxIters = (50000 + pixmaps.size() - 1) / pixmaps.size();
|
||||
for (int it = 0; it < maxIters; ++it)
|
||||
{
|
||||
// std::cerr << "iter " << it << "\n";
|
||||
for (Pixmap &pix : pixmaps)
|
||||
{
|
||||
deltas++;
|
||||
rleBitmap(pix);
|
||||
}
|
||||
}
|
||||
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "took: " <<
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms - ";
|
||||
|
||||
std::cout << "time/rle: " <<
|
||||
(1.0*std::chrono::duration_cast<std::chrono::microseconds>(end - start).count())/deltas << "us\n";
|
||||
}
|
||||
};
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
uint32_t height, width, rowBytes;
|
||||
Pixmap img = Png::loadPng(argv[i], height, width, rowBytes);
|
||||
// std::cout << "Loaded: " << argv[i] << " " << width << "x" << height << "\n";
|
||||
pixmaps.push_back(img);
|
||||
}
|
||||
|
||||
DeltaTests::timeRLE("CPU");
|
||||
|
||||
simd::init();
|
||||
|
||||
DeltaTests::timeRLE("SIMD");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Loading…
Reference in a new issue