mirror of
https://github.com/holub/mame
synced 2025-05-05 05:53:05 +03:00

* Sync with bgfx upstream revision b91d0b6 * Sync with bx upstream revision d60912b * Sync with bimg upstream revision bd81f60 * Add astc-codec decoder * Rename VertexDecl to VertexLayout * Rename UniformType enum Int1 to Sampler. * Add NVN stub * Fix unused-const-variable error on macOS * Drop redundant explicit language parameters buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only applied to objective c++ files. As such, hardcoding -x offers no benefit while preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on macOS) from working. * Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning * Build bgfx as Objective-C++ on macOS It is needed due to included headers * Enable Direct3D12 and Vulkan bgfx rendering backends * Enable building of spirv shaders * Properly escape /c in cmd call * Comment out dx12 bgfx renderer * Honor VERBOSE setting during shaders build * Only invert hlsl shader XYZ_TO_sRGB matrix for opengl * Add spirv shaders * OpenGL ES needs transposed matrix too * Metal needs transposed matrix as well
114 lines
2.5 KiB
C++
114 lines
2.5 KiB
C++
/*
|
|
* Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
|
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
|
|
*/
|
|
|
|
#include <bx/timer.h>
|
|
#include <bx/handlealloc.h>
|
|
#include <bx/maputil.h>
|
|
|
|
#include <tinystl/allocator.h>
|
|
#include <tinystl/unordered_map.h>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
|
|
int main()
|
|
{
|
|
const uint32_t numElements = 4<<10;
|
|
const uint32_t numIterations = 16;
|
|
|
|
//
|
|
{
|
|
int64_t elapsed = -bx::getHPCounter();
|
|
|
|
for (uint32_t ii = 0; ii < numIterations; ++ii)
|
|
{
|
|
typedef tinystl::unordered_map<uint64_t, uint16_t> TinyStlUnorderedMap;
|
|
TinyStlUnorderedMap map;
|
|
// map.reserve(numElements);
|
|
for (uint32_t jj = 0; jj < numElements; ++jj)
|
|
{
|
|
tinystl::pair<TinyStlUnorderedMap::iterator, bool> ok = map.insert(tinystl::make_pair(uint64_t(jj), uint16_t(jj) ) );
|
|
assert(ok.second); BX_UNUSED(ok);
|
|
}
|
|
|
|
for (uint32_t jj = 0; jj < numElements; ++jj)
|
|
{
|
|
bool ok = bx::mapRemove(map, uint64_t(jj) );
|
|
assert(ok); BX_UNUSED(ok);
|
|
}
|
|
|
|
assert(map.size() == 0);
|
|
}
|
|
|
|
elapsed += bx::getHPCounter();
|
|
printf(" TinyStl: %15f\n", double(elapsed) );
|
|
}
|
|
|
|
///
|
|
{
|
|
int64_t elapsed = -bx::getHPCounter();
|
|
|
|
for (uint32_t ii = 0; ii < numIterations; ++ii)
|
|
{
|
|
typedef std::unordered_map<uint64_t, uint16_t> StdUnorderedMap;
|
|
StdUnorderedMap map;
|
|
map.reserve(numElements);
|
|
for (uint32_t jj = 0; jj < numElements; ++jj)
|
|
{
|
|
std::pair<StdUnorderedMap::iterator, bool> ok = map.insert(std::make_pair(uint64_t(jj), uint16_t(jj) ) );
|
|
assert(ok.second); BX_UNUSED(ok);
|
|
}
|
|
|
|
for (uint32_t jj = 0; jj < numElements; ++jj)
|
|
{
|
|
bool ok = bx::mapRemove(map, uint64_t(jj) );
|
|
assert(ok); BX_UNUSED(ok);
|
|
}
|
|
|
|
assert(map.size() == 0);
|
|
}
|
|
|
|
elapsed += bx::getHPCounter();
|
|
printf(" STL: %15f\n", double(elapsed) );
|
|
}
|
|
|
|
///
|
|
{
|
|
int64_t elapsed = -bx::getHPCounter();
|
|
|
|
for (uint32_t ii = 0; ii < numIterations; ++ii)
|
|
{
|
|
typedef bx::HandleHashMapT<numElements+numElements/2, uint64_t> HandleHashMap;
|
|
HandleHashMap map;
|
|
for (uint32_t jj = 0; jj < numElements; ++jj)
|
|
{
|
|
bool ok = map.insert(jj, uint16_t(jj) );
|
|
assert(ok); BX_UNUSED(ok);
|
|
}
|
|
|
|
for (uint32_t jj = 0; jj < numElements; ++jj)
|
|
{
|
|
bool ok = map.removeByKey(uint64_t(jj) );
|
|
assert(ok); BX_UNUSED(ok);
|
|
}
|
|
|
|
assert(map.getNumElements() == 0);
|
|
}
|
|
|
|
elapsed += bx::getHPCounter();
|
|
printf("HandleHashMap: %15f\n", double(elapsed) );
|
|
}
|
|
|
|
extern void simd_bench();
|
|
simd_bench();
|
|
|
|
extern void math_bench();
|
|
math_bench();
|
|
|
|
return bx::kExitSuccess;
|
|
}
|