Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

[Win32] test/benchmark.c broken #75

Closed
gvanem opened this issue Jan 21, 2016 · 2 comments
Closed

[Win32] test/benchmark.c broken #75

gvanem opened this issue Jan 21, 2016 · 2 comments

Comments

@gvanem
Copy link

gvanem commented Jan 21, 2016

This test/benchmark program is not working on Windows due to several things:

  • Hard-coded paths like /usr/local/share/GeoIP/GeoIP.dat.

    IMHO, a macro using SRCDIRshould be used here.

    Or better, a path based on GetModuleFileName() + ../data.
  • MSVC does not have <sys/time.h>.
  • The elapsed time calculation seems broken:
   double timerstop()
   {
       __int64 delta;              /* VC6 can't convert an unsigned int64 to to double */
       GetSystemTimeAsFileTime(&timer_t2);
       delta = FILETIME_TO_USEC(timer_t2) - FILETIME_TO_USEC(timer_t2);
       return delta;
   }

This return # of micro-seconds, not seconds as the non-Win32 version does.

Anyway, with some patching [1] of the above, I seems to get very decent results:

GeoIP Country
120000 lookups made in 2.149048 seconds
GeoIP Country with GEOIP_CHECK_CACHE
120000 lookups made in 2.118030 seconds
GeoIP Country with GEOIP_MEMORY_CACHE
1200000 lookups made in 21.132135 seconds
GeoIP Country with GEOIP_MEMORY_CACHE and GEOIP_CHECK_CACHE
1200000 lookups made in 21.096256 seconds
GeoIP Region
120000 lookups made in 0.522512 seconds
GeoIP Region with GEOIP_CHECK_CACHE
120000 lookups made in 0.522512 seconds
GeoIP Region with GEOIP_MEMORY_CACHE
1200000 lookups made in 5.223323 seconds
GeoIP Region with GEOIP_MEMORY_CACHE and GEOIP_CHECK_CACHE
1200000 lookups made in 5.212008 seconds
GeoIP Org
60000 lookups made in 0.466460 seconds
GeoIP Org with GEOIP_INDEX_CACHE
240000 lookups made in 1.853766 seconds
GeoIP Org with GEOIP_INDEX_CACHE and GEOIP_CHECK_CACHE
240000 lookups made in 1.862786 seconds
GeoIP Org with GEOIP_MEMORY_CACHE
600000 lookups made in 4.680498 seconds
GeoIP City
60000 lookups made in 1.884824 seconds
GeoIP City with GEOIP_INDEX_CACHE
240000 lookups made in 7.531220 seconds
GeoIP City with GEOIP_INDEX_CACHE and GEOIP_CHECK_CACHE
240000 lookups made in 7.524210 seconds
GeoIP City with GEOIP_MEMORY_CACHE
600000 lookups made in 18.783081 seconds

Using TDM-gcc v5.1 with -O2 -fomit-frame-pointer -ffast-math. On Intel i7, 3.5GHz, Win-10,
Can someone on non-Windows with similar hardware confirm these times?

[1] http://www.watt-32.net/misc/GeoIP-API-C-benchmark.diff

@oschwald
Copy link
Member

Thanks! I fixed a minor issue with how GEOIP_SILENCE was being used, which should improve your results further.

@gvanem
Copy link
Author

gvanem commented Jan 21, 2016

.. with how GEOIP_SILENCE ..

Duh me! It should off-course be | GEOIP_SILENCE.

oschwald added a commit that referenced this issue Mar 29, 2017
1.6.10

* GeoIP_database_info now returns the full version string rather than
  incorrectly truncating it. GitHub #79.
* This API is now distributed with a small test copy of GeoIP.dat rather than
  a full copy.
* Fix issue where Visual Studio 2015 was optimizing out initialization code.
  Reported and fixed by Scott Godin. GitHub #81.
* Fix test/benchmark on Windows. Gisle Vanem. GitHub #75.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants