2013-11-19 21:23:37 +01:00
|
|
|
#include "bench_framework.hpp"
|
|
|
|
#include <mapnik/font_engine_freetype.hpp>
|
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
|
|
|
class test : public benchmark::test_case
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
test(mapnik::parameters const& params)
|
|
|
|
: test_case(params) {}
|
|
|
|
bool validate() const
|
|
|
|
{
|
2014-09-25 22:09:05 +02:00
|
|
|
std::size_t count = 0;
|
|
|
|
std::size_t expected_count = mapnik::freetype_engine::face_names().size();
|
|
|
|
mapnik::freetype_engine engine;
|
|
|
|
for (std::string const& name : mapnik::freetype_engine::face_names())
|
|
|
|
{
|
|
|
|
mapnik::face_ptr f = engine.create_face(name);
|
|
|
|
if (f) ++count;
|
|
|
|
}
|
|
|
|
return count == expected_count;
|
2013-11-19 21:23:37 +01:00
|
|
|
}
|
|
|
|
void operator()() const
|
|
|
|
{
|
|
|
|
mapnik::freetype_engine engine;
|
2014-09-25 22:09:05 +02:00
|
|
|
std::size_t expected_count = mapnik::freetype_engine::face_names().size();
|
2013-11-19 21:23:37 +01:00
|
|
|
for (unsigned i=0;i<iterations_;++i)
|
|
|
|
{
|
2014-09-25 22:09:05 +02:00
|
|
|
std::size_t count = 0;
|
|
|
|
for (std::string const& name : mapnik::freetype_engine::face_names())
|
2013-11-19 21:23:37 +01:00
|
|
|
{
|
|
|
|
mapnik::face_ptr f = engine.create_face(name);
|
|
|
|
if (f) ++count;
|
|
|
|
}
|
2014-09-25 22:09:05 +02:00
|
|
|
if (count != expected_count) {
|
|
|
|
std::clog << "warning: face creation not working as expected\n";
|
|
|
|
}
|
2013-11-19 21:23:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
mapnik::parameters params;
|
|
|
|
benchmark::handle_args(argc,argv,params);
|
|
|
|
bool success = mapnik::freetype_engine::register_fonts("./fonts", true);
|
|
|
|
if (!success) {
|
|
|
|
std::clog << "warning, did not register any new fonts!\n";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
std::size_t face_count = mapnik::freetype_engine::face_names().size();
|
|
|
|
test test_runner(params);
|
2014-09-25 22:09:05 +02:00
|
|
|
return run(test_runner,(boost::format("font_engine: creating %ld faces") % (face_count)).str());
|
2013-11-19 21:23:37 +01:00
|
|
|
}
|
|
|
|
|