diff --git a/examples/AutoBenchmark/AutoBenchmark.ino b/examples/AutoBenchmark/AutoBenchmark.ino index b7ebf66f2..567d6b338 100644 --- a/examples/AutoBenchmark/AutoBenchmark.ino +++ b/examples/AutoBenchmark/AutoBenchmark.ino @@ -56,57 +56,126 @@ void setup() { SERIAL_PORT_MONITOR.print(F("sizeof(TimePeriod): ")); SERIAL_PORT_MONITOR.println(sizeof(TimePeriod)); - SERIAL_PORT_MONITOR.print(F("sizeof(BasicZoneProcessor): ")); - SERIAL_PORT_MONITOR.println(sizeof(BasicZoneProcessor)); - - SERIAL_PORT_MONITOR.print(F("sizeof(ExtendedZoneProcessor): ")); - SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessor)); + // Basic - SERIAL_PORT_MONITOR.print(F("sizeof(BasicZoneProcessorCache<1>): ")); - SERIAL_PORT_MONITOR.println(sizeof(BasicZoneProcessorCache<1>)); + SERIAL_PORT_MONITOR.println(F("Basic:")); - SERIAL_PORT_MONITOR.print(F("sizeof(ExtendedZoneProcessorCache<1>): ")); - SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessorCache<1>)); - - SERIAL_PORT_MONITOR.print(F("sizeof(BasicZoneManager): ")); - SERIAL_PORT_MONITOR.println(sizeof(BasicZoneManager)); - - SERIAL_PORT_MONITOR.print(F("sizeof(ExtendedZoneManager): ")); - SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneManager)); - - // ace_time::basic and ace_time::extended classes - - SERIAL_PORT_MONITOR.print(F("sizeof(basic::ZoneContext): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(basic::ZoneContext): ")); SERIAL_PORT_MONITOR.println(sizeof(basic::ZoneContext)); - SERIAL_PORT_MONITOR.print(F("sizeof(basic::ZoneEra): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(basic::ZoneEra): ")); SERIAL_PORT_MONITOR.println(sizeof(basic::ZoneEra)); - SERIAL_PORT_MONITOR.print(F("sizeof(basic::ZoneInfo): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(basic::ZoneInfo): ")); SERIAL_PORT_MONITOR.println(sizeof(basic::ZoneInfo)); - SERIAL_PORT_MONITOR.print(F("sizeof(basic::ZoneRule): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(basic::ZoneRule): ")); SERIAL_PORT_MONITOR.println(sizeof(basic::ZoneRule)); - SERIAL_PORT_MONITOR.print(F("sizeof(basic::ZonePolicy): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(basic::ZonePolicy): ")); SERIAL_PORT_MONITOR.println(sizeof(basic::ZonePolicy)); - SERIAL_PORT_MONITOR.print(F("sizeof(basic::ZoneRegistrar): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(basic::ZoneRegistrar): ")); SERIAL_PORT_MONITOR.println(sizeof(basic::ZoneRegistrar)); - SERIAL_PORT_MONITOR.print(F("sizeof(BasicZoneProcessor::Transition): ")); + SERIAL_PORT_MONITOR.print(F(" sizeof(BasicZoneProcessor): ")); + SERIAL_PORT_MONITOR.println(sizeof(BasicZoneProcessor)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(BasicZoneProcessorCache<1>): ")); + SERIAL_PORT_MONITOR.println(sizeof(BasicZoneProcessorCache<1>)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(BasicZoneManager): ")); + SERIAL_PORT_MONITOR.println(sizeof(BasicZoneManager)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(BasicZoneProcessor::Transition): ")); SERIAL_PORT_MONITOR.println(sizeof(BasicZoneProcessor::Transition)); - SERIAL_PORT_MONITOR.print(F("sizeof(ExtendedZoneProcessor::Transition): ")); + // Extended + + SERIAL_PORT_MONITOR.println(F("Extended:")); + + SERIAL_PORT_MONITOR.print(F(" sizeof(extended::ZoneContext): ")); + SERIAL_PORT_MONITOR.println(sizeof(extended::ZoneContext)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(extended::ZoneEra): ")); + SERIAL_PORT_MONITOR.println(sizeof(extended::ZoneEra)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(extended::ZoneInfo): ")); + SERIAL_PORT_MONITOR.println(sizeof(extended::ZoneInfo)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(extended::ZoneRule): ")); + SERIAL_PORT_MONITOR.println(sizeof(extended::ZoneRule)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(extended::ZonePolicy): ")); + SERIAL_PORT_MONITOR.println(sizeof(extended::ZonePolicy)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(extended::ZoneRegistrar): ")); + SERIAL_PORT_MONITOR.println(sizeof(extended::ZoneRegistrar)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(ExtendedZoneProcessor): ")); + SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessor)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(ExtendedZoneProcessorCache<1>): ")); + SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessorCache<1>)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(ExtendedZoneManager): ")); + SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneManager)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(ExtendedZoneProcessor::Transition): ")); SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessor::Transition)); SERIAL_PORT_MONITOR.print( - F("sizeof(ExtendedZoneProcessor::TransitionStorage): ")); + F(" sizeof(ExtendedZoneProcessor::TransitionStorage): ")); SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessor::TransitionStorage)); - SERIAL_PORT_MONITOR.print(F("sizeof(ExtendedZoneProcessor::MatchingEra): ")); + SERIAL_PORT_MONITOR.print( + F(" sizeof(ExtendedZoneProcessor::MatchingEra): ")); SERIAL_PORT_MONITOR.println(sizeof(ExtendedZoneProcessor::MatchingEra)); + // Complete + + SERIAL_PORT_MONITOR.println(F("Complete:")); + + SERIAL_PORT_MONITOR.print(F(" sizeof(complete::ZoneContext): ")); + SERIAL_PORT_MONITOR.println(sizeof(complete::ZoneContext)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(complete::ZoneEra): ")); + SERIAL_PORT_MONITOR.println(sizeof(complete::ZoneEra)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(complete::ZoneInfo): ")); + SERIAL_PORT_MONITOR.println(sizeof(complete::ZoneInfo)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(complete::ZoneRule): ")); + SERIAL_PORT_MONITOR.println(sizeof(complete::ZoneRule)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(complete::ZonePolicy): ")); + SERIAL_PORT_MONITOR.println(sizeof(complete::ZonePolicy)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(complete::ZoneRegistrar): ")); + SERIAL_PORT_MONITOR.println(sizeof(complete::ZoneRegistrar)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(CompleteZoneProcessor): ")); + SERIAL_PORT_MONITOR.println(sizeof(CompleteZoneProcessor)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(CompleteZoneProcessorCache<1>): ")); + SERIAL_PORT_MONITOR.println(sizeof(CompleteZoneProcessorCache<1>)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(CompleteZoneManager): ")); + SERIAL_PORT_MONITOR.println(sizeof(CompleteZoneManager)); + + SERIAL_PORT_MONITOR.print(F(" sizeof(CompleteZoneProcessor::Transition): ")); + SERIAL_PORT_MONITOR.println(sizeof(CompleteZoneProcessor::Transition)); + + SERIAL_PORT_MONITOR.print( + F(" sizeof(CompleteZoneProcessor::TransitionStorage): ")); + SERIAL_PORT_MONITOR.println(sizeof(CompleteZoneProcessor::TransitionStorage)); + + SERIAL_PORT_MONITOR.print( + F(" sizeof(CompleteZoneProcessor::MatchingEra): ")); + SERIAL_PORT_MONITOR.println(sizeof(CompleteZoneProcessor::MatchingEra)); + + // ace_time::basic and ace_time::extended classes + SERIAL_PORT_MONITOR.println(F("BENCHMARKS")); runBenchmarks(); SERIAL_PORT_MONITOR.println(F("END")); diff --git a/examples/AutoBenchmark/Benchmark.cpp b/examples/AutoBenchmark/Benchmark.cpp index 2231da281..b0215bb99 100644 --- a/examples/AutoBenchmark/Benchmark.cpp +++ b/examples/AutoBenchmark/Benchmark.cpp @@ -16,7 +16,7 @@ * runLocalDateToEpochDays(), reverted). * * * Sketch uses 28136 bytes (91%) of program storage space. Maximum is 30720 - * bytes. (After creating a custom kBenchmarkZoneRegistry with only 83 zones.) + * bytes. (After creating a custom kBasicRegistry with only 83 zones.) * * * Sketch uses 28036 bytes (91%) of program storage space. Maximum is 30720 * bytes. (After moving elapsedMillis calculation into printResult(). @@ -45,18 +45,22 @@ #include // PrintStr #include #include "Benchmark.h" -#include "zone_registry.h" +#include "basic_registry.h" +#include "extended_registry.h" +#include "complete_registry.h" using namespace ace_time; using ace_common::PrintStr; -// Sometimes, depending on the size of the AceTime library, the SparkFun -// ProMicro does not have enough flash, so this allows us to disable -// ExtendedZoneProcessor when needed. +// AVR microcontrollers like the SparkFun ProMicro and Arduino Nano do not have +// enough flash memory, so this allows us to enable the ExtendedZoneProcessor +// and CompleteZoneProcessor only when needed. #if defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_NANO) #define ENABLE_EXTENDED_ZONE_PROCESSOR 0 + #define ENABLE_COMPLETE_ZONE_PROCESSOR 0 #else #define ENABLE_EXTENDED_ZONE_PROCESSOR 1 + #define ENABLE_COMPLETE_ZONE_PROCESSOR 1 #endif #if defined(ARDUINO_ARCH_AVR) @@ -64,9 +68,9 @@ const uint32_t COUNT = 1000; #elif defined(ARDUINO_ARCH_SAMD) const uint32_t COUNT = 5000; #elif defined(ARDUINO_ARCH_STM32) -const uint32_t COUNT = 10000; -#elif defined(ESP8266) const uint32_t COUNT = 5000; +#elif defined(ESP8266) +const uint32_t COUNT = 2000; // low enough to prevent WDT exception #elif defined(ESP32) const uint32_t COUNT = 20000; #elif defined(TEENSYDUINO) @@ -365,7 +369,13 @@ static BasicZoneProcessor* basicZoneProcessor; static ExtendedZoneProcessor* extendedZoneProcessor; #endif -// ZonedDateTime::forEpochSeconds(seconds, tz), uncached +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 1 + static CompleteZoneProcessor* completeZoneProcessor; +#endif + +//----------------------------------------------------------------------------- + +// ZonedDateTime::forEpochSeconds(seconds, tz), Basic uncached static void runZonedDateTimeForEpochSecondsBasicNoCache() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -386,7 +396,7 @@ static void runZonedDateTimeForEpochSecondsBasicNoCache() { forEpochSecondsMillis, emptyLoopMillis); } -// ZonedDateTime::forEpochSeconds(seconds, tz), cached +// ZonedDateTime::forEpochSeconds(seconds, tz), Basic cached static void runZonedDateTimeForEpochSecondsBasicCached() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -405,7 +415,7 @@ static void runZonedDateTimeForEpochSecondsBasicCached() { forEpochSecondsMillis, emptyLoopMillis); } -// ZonedDateTime::forEpochSeconds(seconds, tz), uncached +// ZonedDateTime::forEpochSeconds(seconds, tz), Extended uncached static void runZonedDateTimeForEpochSecondsExtendedNoCache() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedDateTime::forEpochSeconds(Extended_nocache)")); @@ -431,7 +441,7 @@ static void runZonedDateTimeForEpochSecondsExtendedNoCache() { #endif } -// ZonedDateTime::forEpochSeconds(seconds, tz), cached +// ZonedDateTime::forEpochSeconds(seconds, tz), Extended cached static void runZonedDateTimeForEpochSecondsExtendedCached() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedDateTime::forEpochSeconds(Extended_cached)")); @@ -455,9 +465,59 @@ static void runZonedDateTimeForEpochSecondsExtendedCached() { #endif } +// ZonedDateTime::forEpochSeconds(seconds, tz), Complete uncached +static void runZonedDateTimeForEpochSecondsCompleteNoCache() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedDateTime::forEpochSeconds(Complete_nocache)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + offset = 0; + + unsigned long forEpochSecondsMillis = runLambda([]() { + offset = (offset) ? 0 : kTwoYears; + fakeEpochSeconds = millis() + offset; + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedDateTime dateTime = ZonedDateTime::forEpochSeconds( + fakeEpochSeconds, tzLosAngeles); + disableOptimization(dateTime); + }); + + printResult(F("ZonedDateTime::forEpochSeconds(Complete_nocache)"), + forEpochSecondsMillis, emptyLoopMillis); +#endif +} + +// ZonedDateTime::forEpochSeconds(seconds, tz), Complete cached +static void runZonedDateTimeForEpochSecondsCompleteCached() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedDateTime::forEpochSeconds(Complete_cached)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + fakeEpochSeconds = millis() & 0xffff; + + unsigned long forEpochSecondsMillis = runLambda([]() { + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedDateTime dateTime = ZonedDateTime::forEpochSeconds( + fakeEpochSeconds, tzLosAngeles); + disableOptimization(dateTime); + }); + + printResult(F("ZonedDateTime::forEpochSeconds(Complete_cached)"), + forEpochSecondsMillis, emptyLoopMillis); +#endif +} + //----------------------------------------------------------------------------- -// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), uncached +// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), Basic uncached static void runZonedDateTimeForComponentsBasicNoCache() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -476,7 +536,7 @@ static void runZonedDateTimeForComponentsBasicNoCache() { forComponentsMillis, emptyLoopMillis); } -// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), cached +// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), Basic cached static void runZonedDateTimeForComponentsBasicCached() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -495,7 +555,7 @@ static void runZonedDateTimeForComponentsBasicCached() { forComponentsMillis, emptyLoopMillis); } -// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), uncached +// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), Extended uncached static void runZonedDateTimeForComponentsExtendedNoCache() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedDateTime::forComponents(Extended_nocache)")); @@ -519,7 +579,7 @@ static void runZonedDateTimeForComponentsExtendedNoCache() { #endif } -// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), cached +// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), Extended cached static void runZonedDateTimeForComponentsExtendedCached() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedDateTime::forComponents(Extended_cached)")); @@ -543,9 +603,57 @@ static void runZonedDateTimeForComponentsExtendedCached() { #endif } +// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), Complete uncached +static void runZonedDateTimeForComponentsCompleteNoCache() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedDateTime::forComponents(Complete_nocache)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + + unsigned long forComponentsMillis = runLambda([]() { + year = (year == 2000) ? 2002 : 2000; + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedDateTime dateTime = ZonedDateTime::forComponents( + year, 3, 1, 0, 0, 0, tzLosAngeles); + disableOptimization(dateTime); + }); + + printResult(F("ZonedDateTime::forComponents(Complete_nocache)"), + forComponentsMillis, emptyLoopMillis); +#endif +} + +// ZonedDateTime::forComponents(year, m, d, h, m, s, tz), Complete cached +static void runZonedDateTimeForComponentsCompleteCached() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedDateTime::forComponents(Complete_cached)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + year = 2000; + + unsigned long forComponentsMillis = runLambda([]() { + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedDateTime dateTime = ZonedDateTime::forComponents( + year, 3, 1, 0, 0, 0, tzLosAngeles); + disableOptimization(dateTime); + }); + + printResult(F("ZonedDateTime::forComponents(Complete_cached)"), + forComponentsMillis, emptyLoopMillis); +#endif +} + //----------------------------------------------------------------------------- -// ZonedExtra::forEpochSeconds(seconds, tz), uncached +// ZonedExtra::forEpochSeconds(seconds, tz), Basic uncached static void runZonedExtraForEpochSecondsBasicNoCache() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -566,7 +674,7 @@ static void runZonedExtraForEpochSecondsBasicNoCache() { forEpochSecondsMillis, emptyLoopMillis); } -// ZonedExtra::forEpochSeconds(seconds, tz), cached +// ZonedExtra::forEpochSeconds(seconds, tz), Basic cached static void runZonedExtraForEpochSecondsBasicCached() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -585,7 +693,7 @@ static void runZonedExtraForEpochSecondsBasicCached() { forEpochSecondsMillis, emptyLoopMillis); } -// ZonedExtra::forEpochSeconds(seconds, tz), uncached +// ZonedExtra::forEpochSeconds(seconds, tz), Extended uncached static void runZonedExtraForEpochSecondsExtendedNoCache() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedExtra::forEpochSeconds(Extended_nocache)")); @@ -611,7 +719,7 @@ static void runZonedExtraForEpochSecondsExtendedNoCache() { #endif } -// ZonedExtra::forEpochSeconds(seconds, tz), cached +// ZonedExtra::forEpochSeconds(seconds, tz), Extended cached static void runZonedExtraForEpochSecondsExtendedCached() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedExtra::forEpochSeconds(Extended_cached)")); @@ -635,9 +743,59 @@ static void runZonedExtraForEpochSecondsExtendedCached() { #endif } +// ZonedExtra::forEpochSeconds(seconds, tz), Complete uncached +static void runZonedExtraForEpochSecondsCompleteNoCache() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedExtra::forEpochSeconds(Complete_nocache)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + offset = 0; + + unsigned long forEpochSecondsMillis = runLambda([]() { + offset = (offset) ? 0 : kTwoYears; + fakeEpochSeconds = millis() + offset; + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedExtra extra = ZonedExtra::forEpochSeconds( + fakeEpochSeconds, tzLosAngeles); + disableOptimization(extra); + }); + + printResult(F("ZonedExtra::forEpochSeconds(Complete_nocache)"), + forEpochSecondsMillis, emptyLoopMillis); +#endif +} + +// ZonedExtra::forEpochSeconds(seconds, tz), Complete cached +static void runZonedExtraForEpochSecondsCompleteCached() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedExtra::forEpochSeconds(Complete_cached)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + fakeEpochSeconds = millis() & 0xffff; + + unsigned long forEpochSecondsMillis = runLambda([]() { + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedExtra extra = ZonedExtra::forEpochSeconds( + fakeEpochSeconds, tzLosAngeles); + disableOptimization(extra); + }); + + printResult(F("ZonedExtra::forEpochSeconds(Complete_cached)"), + forEpochSecondsMillis, emptyLoopMillis); +#endif +} + //----------------------------------------------------------------------------- -// ZonedExtra::forComponents(year, m, d, h, m, s, tz), uncached +// ZonedExtra::forComponents(year, m, d, h, m, s, tz), Basic uncached static void runZonedExtraForComponentsBasicNoCache() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -656,7 +814,7 @@ static void runZonedExtraForComponentsBasicNoCache() { forComponentsMillis, emptyLoopMillis); } -// ZonedExtra::forComponents(year, m, d, h, m, s, tz), cached +// ZonedExtra::forComponents(year, m, d, h, m, s, tz), Basic cached static void runZonedExtraForComponentsBasicCached() { BasicZoneProcessor processor; basicZoneProcessor = &processor; @@ -675,7 +833,7 @@ static void runZonedExtraForComponentsBasicCached() { forComponentsMillis, emptyLoopMillis); } -// ZonedExtra::forComponents(year, m, d, h, m, s, tz), uncached +// ZonedExtra::forComponents(year, m, d, h, m, s, tz), Extended uncached static void runZonedExtraForComponentsExtendedNoCache() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedExtra::forComponents(Extended_nocache)")); @@ -699,7 +857,7 @@ static void runZonedExtraForComponentsExtendedNoCache() { #endif } -// ZonedExtra::forComponents(year, m, d, h, m, s, tz), cached +// ZonedExtra::forComponents(year, m, d, h, m, s, tz), Extended cached static void runZonedExtraForComponentsExtendedCached() { #if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 printNullResult(F("ZonedExtra::forComponents(Extended_cached)")); @@ -723,24 +881,65 @@ static void runZonedExtraForComponentsExtendedCached() { #endif } -//----------------------------------------------------------------------------- +// ZonedExtra::forComponents(year, m, d, h, m, s, tz), Complete uncached +static void runZonedExtraForComponentsCompleteNoCache() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedExtra::forComponents(Complete_nocache)")); -// This sketch is small enough to run on an Arduino Nano with about ~32kB. It -// currently squeezes just under the ~30kB limit for a SparkFun Pro Micro. -// "Sketch uses 28394 bytes (99%) of program storage space. Maximum is 28672 -// bytes." +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + + unsigned long forComponentsMillis = runLambda([]() { + year = (year == 2000) ? 2002 : 2000; + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedExtra extra = ZonedExtra::forComponents( + year, 3, 1, 0, 0, 0, tzLosAngeles); + disableOptimization(extra); + }); + + printResult(F("ZonedExtra::forComponents(Complete_nocache)"), + forComponentsMillis, emptyLoopMillis); +#endif +} + +// ZonedExtra::forComponents(year, m, d, h, m, s, tz), Complete cached +static void runZonedExtraForComponentsCompleteCached() { +#if ENABLE_COMPLETE_ZONE_PROCESSOR == 0 + printNullResult(F("ZonedExtra::forComponents(Complete_cached)")); + +#else + CompleteZoneProcessor processor; + completeZoneProcessor = &processor; + year = 2000; + + unsigned long forComponentsMillis = runLambda([]() { + TimeZone tzLosAngeles = TimeZone::forZoneInfo( + &zonedbc::kZoneAmerica_Los_Angeles, + completeZoneProcessor); + ZonedExtra extra = ZonedExtra::forComponents( + year, 3, 1, 0, 0, 0, tzLosAngeles); + disableOptimization(extra); + }); + + printResult(F("ZonedExtra::forComponents(Complete_cached)"), + forComponentsMillis, emptyLoopMillis); +#endif +} + +//----------------------------------------------------------------------------- basic::ZoneRegistrar* basicZoneRegistrar; -static void runIndexForZoneName() { - basic::ZoneRegistrar registrar( - kBenchmarkZoneRegistrySize, - kBenchmarkZoneRegistry); +void runBasicRegistrarFindIndexForName() { + basic::ZoneRegistrar registrar(kBasicRegistrySize, kBasicRegistry); basicZoneRegistrar = ®istrar; unsigned long runMillis = runLambda([]() { PrintStr<40> printStr; - uint16_t randomIndex = random(kBenchmarkZoneRegistrySize); + uint16_t randomIndex = random(kBasicRegistrySize); const basic::ZoneInfo* info = basicZoneRegistrar->getZoneInfoForIndex( randomIndex); BasicZone(info).printNameTo(printStr); @@ -754,7 +953,7 @@ static void runIndexForZoneName() { unsigned long emptyLoopMillis = runLambda([]() { PrintStr<40> printStr; - uint16_t randomIndex = random(kBenchmarkZoneRegistrySize); + uint16_t randomIndex = random(kBasicRegistrySize); const basic::ZoneInfo* info = basicZoneRegistrar->getZoneInfoForIndex( randomIndex); BasicZone(info).printNameTo(printStr); @@ -768,19 +967,17 @@ static void runIndexForZoneName() { disableOptimization((uint32_t) tmp); }); - printResult(F("BasicZoneManager::createForZoneName(binary)"), runMillis, + printResult(F("BasicZoneRegistrar::findIndexForName(binary)"), runMillis, emptyLoopMillis); } // non-static to allow friend access into basic::ZoneRegistrar -void runIndexForZoneIdBinary() { - basic::ZoneRegistrar registrar( - kBenchmarkZoneRegistrySize, - kBenchmarkZoneRegistry); +void runBasicRegistrarFindIndexForIdBinary() { + basic::ZoneRegistrar registrar(kBasicRegistrySize, kBasicRegistry); basicZoneRegistrar = ®istrar; unsigned long runMillis = runLambda([]() { - uint16_t randomIndex = random(kBenchmarkZoneRegistrySize); + uint16_t randomIndex = random(kBasicRegistrySize); const basic::ZoneInfo* info = basicZoneRegistrar->getZoneInfoForIndex( randomIndex); uint32_t zoneId = BasicZone(info).zoneId(); @@ -793,7 +990,7 @@ void runIndexForZoneIdBinary() { }); unsigned long emptyLoopMillis = runLambda([]() { - uint16_t randomIndex = random(kBenchmarkZoneRegistrySize); + uint16_t randomIndex = random(kBasicRegistrySize); const basic::ZoneInfo* info = basicZoneRegistrar->getZoneInfoForIndex( randomIndex); uint32_t zoneId = BasicZone(info).zoneId(); @@ -801,20 +998,18 @@ void runIndexForZoneIdBinary() { disableOptimization(zoneId); }); - printResult(F("BasicZoneManager::createForZoneId(binary)"), runMillis, + printResult(F("BasicZoneRegistrar::findIndexForIdBinary()"), runMillis, emptyLoopMillis); } // non-static to allow friend access into basic::ZoneRegistrar -void runIndexForZoneIdLinear() { - basic::ZoneRegistrar registrar( - kBenchmarkZoneRegistrySize, - kBenchmarkZoneRegistry); +void runBasicRegistrarFindIndexForIdLinear() { + basic::ZoneRegistrar registrar(kBasicRegistrySize, kBasicRegistry); basicZoneRegistrar = ®istrar; unsigned long runMillis = runLambda([]() { - uint16_t randomIndex = random(kBenchmarkZoneRegistrySize); - const basic::ZoneInfo* info = kBenchmarkZoneRegistry[randomIndex]; + uint16_t randomIndex = random(kBasicRegistrySize); + const basic::ZoneInfo* info = kBasicRegistry[randomIndex]; uint32_t zoneId = BasicZone(info).zoneId(); uint16_t index = basicZoneRegistrar->findIndexForIdLinear(zoneId); @@ -822,19 +1017,265 @@ void runIndexForZoneIdLinear() { }); unsigned long emptyLoopMillis = runLambda([]() { - uint16_t randomIndex = random(kBenchmarkZoneRegistrySize); - const basic::ZoneInfo* info = kBenchmarkZoneRegistry[randomIndex]; + uint16_t randomIndex = random(kBasicRegistrySize); + const basic::ZoneInfo* info = kBasicRegistry[randomIndex]; uint32_t zoneId = BasicZone(info).zoneId(); disableOptimization(zoneId); }); - printResult(F("BasicZoneManager::createForZoneId(linear)"), runMillis, + printResult(F("BasicZoneRegistrar::findIndexForIdLinear()"), runMillis, emptyLoopMillis); } //----------------------------------------------------------------------------- +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 1 +extended::ZoneRegistrar* extendedZoneRegistrar; +#endif + +void runExtendedRegistrarFindIndexForName() { + const __FlashStringHelper* const label = + F("ExtendedZoneRegistrar::findIndexForName(binary)"); + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 + printNullResult(label); + +#else + + extended::ZoneRegistrar registrar(kExtendedRegistrySize, kExtendedRegistry); + extendedZoneRegistrar = ®istrar; + + unsigned long runMillis = runLambda([]() { + PrintStr<40> printStr; + uint16_t randomIndex = random(kExtendedRegistrySize); + const extended::ZoneInfo* info = extendedZoneRegistrar->getZoneInfoForIndex( + randomIndex); + ExtendedZone(info).printNameTo(printStr); + + uint16_t index = extendedZoneRegistrar->findIndexForName(printStr.cstr()); + if (index == extended::ZoneRegistrar::kInvalidIndex) { + SERIAL_PORT_MONITOR.println(F("Not found")); + } + disableOptimization(index); + }); + + unsigned long emptyLoopMillis = runLambda([]() { + PrintStr<40> printStr; + uint16_t randomIndex = random(kExtendedRegistrySize); + const extended::ZoneInfo* info = extendedZoneRegistrar->getZoneInfoForIndex( + randomIndex); + ExtendedZone(info).printNameTo(printStr); + + uint16_t len = printStr.length(); + const char* s = printStr.cstr(); + uint32_t tmp = s[0] + + ((len > 1) ? ((uint32_t) s[1] << 8) : 0) + + ((len > 2) ? ((uint32_t) s[2] << 16) : 0) + + ((len > 3) ? ((uint32_t) s[3] << 24) : 0); + disableOptimization((uint32_t) tmp); + }); + + printResult(label, runMillis, emptyLoopMillis); +#endif +} + +// non-static to allow friend access into extended::ZoneRegistrar +void runExtendedRegistrarFindIndexForIdBinary() { + const __FlashStringHelper* const label = + F("ExtendedZoneRegistrar::findIndexForIdBinary()"); + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 + printNullResult(label); + +#else + extended::ZoneRegistrar registrar(kExtendedRegistrySize, kExtendedRegistry); + extendedZoneRegistrar = ®istrar; + + unsigned long runMillis = runLambda([]() { + uint16_t randomIndex = random(kExtendedRegistrySize); + const extended::ZoneInfo* info = extendedZoneRegistrar->getZoneInfoForIndex( + randomIndex); + uint32_t zoneId = ExtendedZone(info).zoneId(); + + uint16_t index = extendedZoneRegistrar->findIndexForIdBinary(zoneId); + if (index == extended::ZoneRegistrar::kInvalidIndex) { + SERIAL_PORT_MONITOR.println(F("Not found")); + } + disableOptimization(index); + }); + + unsigned long emptyLoopMillis = runLambda([]() { + uint16_t randomIndex = random(kExtendedRegistrySize); + const extended::ZoneInfo* info = extendedZoneRegistrar->getZoneInfoForIndex( + randomIndex); + uint32_t zoneId = ExtendedZone(info).zoneId(); + + disableOptimization(zoneId); + }); + + printResult(label, runMillis, emptyLoopMillis); +#endif +} + +// non-static to allow friend access into extended::ZoneRegistrar +void runExtendedRegistrarFindIndexForIdLinear() { + const __FlashStringHelper* const label = + F("ExtendedZoneRegistrar::findIndexForIdLinear()"); + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 + printNullResult(label); + +#else + extended::ZoneRegistrar registrar(kExtendedRegistrySize, kExtendedRegistry); + extendedZoneRegistrar = ®istrar; + + unsigned long runMillis = runLambda([]() { + uint16_t randomIndex = random(kExtendedRegistrySize); + const extended::ZoneInfo* info = kExtendedRegistry[randomIndex]; + uint32_t zoneId = ExtendedZone(info).zoneId(); + + uint16_t index = extendedZoneRegistrar->findIndexForIdLinear(zoneId); + disableOptimization(index); + }); + + unsigned long emptyLoopMillis = runLambda([]() { + uint16_t randomIndex = random(kExtendedRegistrySize); + const extended::ZoneInfo* info = kExtendedRegistry[randomIndex]; + uint32_t zoneId = ExtendedZone(info).zoneId(); + + disableOptimization(zoneId); + }); + + printResult(label, runMillis, emptyLoopMillis); +#endif +} + +//----------------------------------------------------------------------------- + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 1 +complete::ZoneRegistrar* completeZoneRegistrar; +#endif + +void runCompleteRegistrarFindIndexForName() { + const __FlashStringHelper* const label = + F("CompleteZoneRegistrar::findIndexForName(binary)"); + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 + printNullResult(label); + +#else + + complete::ZoneRegistrar registrar(kCompleteRegistrySize, kCompleteRegistry); + completeZoneRegistrar = ®istrar; + + unsigned long runMillis = runLambda([]() { + PrintStr<40> printStr; + uint16_t randomIndex = random(kCompleteRegistrySize); + const complete::ZoneInfo* info = completeZoneRegistrar->getZoneInfoForIndex( + randomIndex); + CompleteZone(info).printNameTo(printStr); + + uint16_t index = completeZoneRegistrar->findIndexForName(printStr.cstr()); + if (index == complete::ZoneRegistrar::kInvalidIndex) { + SERIAL_PORT_MONITOR.println(F("Not found")); + } + disableOptimization(index); + }); + + unsigned long emptyLoopMillis = runLambda([]() { + PrintStr<40> printStr; + uint16_t randomIndex = random(kCompleteRegistrySize); + const complete::ZoneInfo* info = completeZoneRegistrar->getZoneInfoForIndex( + randomIndex); + CompleteZone(info).printNameTo(printStr); + + uint16_t len = printStr.length(); + const char* s = printStr.cstr(); + uint32_t tmp = s[0] + + ((len > 1) ? ((uint32_t) s[1] << 8) : 0) + + ((len > 2) ? ((uint32_t) s[2] << 16) : 0) + + ((len > 3) ? ((uint32_t) s[3] << 24) : 0); + disableOptimization((uint32_t) tmp); + }); + + printResult(label, runMillis, emptyLoopMillis); +#endif +} + +// non-static to allow friend access into complete::ZoneRegistrar +void runCompleteRegistrarFindIndexForIdBinary() { + const __FlashStringHelper* const label = + F("CompleteZoneRegistrar::findIndexForIdBinary()"); + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 + printNullResult(label); + +#else + complete::ZoneRegistrar registrar(kCompleteRegistrySize, kCompleteRegistry); + completeZoneRegistrar = ®istrar; + + unsigned long runMillis = runLambda([]() { + uint16_t randomIndex = random(kCompleteRegistrySize); + const complete::ZoneInfo* info = completeZoneRegistrar->getZoneInfoForIndex( + randomIndex); + uint32_t zoneId = CompleteZone(info).zoneId(); + + uint16_t index = completeZoneRegistrar->findIndexForIdBinary(zoneId); + if (index == complete::ZoneRegistrar::kInvalidIndex) { + SERIAL_PORT_MONITOR.println(F("Not found")); + } + disableOptimization(index); + }); + + unsigned long emptyLoopMillis = runLambda([]() { + uint16_t randomIndex = random(kCompleteRegistrySize); + const complete::ZoneInfo* info = completeZoneRegistrar->getZoneInfoForIndex( + randomIndex); + uint32_t zoneId = CompleteZone(info).zoneId(); + + disableOptimization(zoneId); + }); + + printResult(label, runMillis, emptyLoopMillis); +#endif +} + +// non-static to allow friend access into complete::ZoneRegistrar +void runCompleteRegistrarFindIndexForIdLinear() { + const __FlashStringHelper* const label = + F("CompleteZoneRegistrar::findIndexForIdLinear()"); + +#if ENABLE_EXTENDED_ZONE_PROCESSOR == 0 + printNullResult(label); + +#else + complete::ZoneRegistrar registrar(kCompleteRegistrySize, kCompleteRegistry); + completeZoneRegistrar = ®istrar; + + unsigned long runMillis = runLambda([]() { + uint16_t randomIndex = random(kCompleteRegistrySize); + const complete::ZoneInfo* info = kCompleteRegistry[randomIndex]; + uint32_t zoneId = CompleteZone(info).zoneId(); + + uint16_t index = completeZoneRegistrar->findIndexForIdLinear(zoneId); + disableOptimization(index); + }); + + unsigned long emptyLoopMillis = runLambda([]() { + uint16_t randomIndex = random(kCompleteRegistrySize); + const complete::ZoneInfo* info = kCompleteRegistry[randomIndex]; + uint32_t zoneId = CompleteZone(info).zoneId(); + + disableOptimization(zoneId); + }); + + printResult(label, runMillis, emptyLoopMillis); +#endif +} + +//----------------------------------------------------------------------------- + void runBenchmarks() { runEmptyLoop(); @@ -853,25 +1294,41 @@ void runBenchmarks() { runZonedDateTimeForEpochSecondsBasicCached(); runZonedDateTimeForEpochSecondsExtendedNoCache(); runZonedDateTimeForEpochSecondsExtendedCached(); + runZonedDateTimeForEpochSecondsCompleteNoCache(); + runZonedDateTimeForEpochSecondsCompleteCached(); runZonedDateTimeForComponentsBasicNoCache(); runZonedDateTimeForComponentsBasicCached(); runZonedDateTimeForComponentsExtendedNoCache(); runZonedDateTimeForComponentsExtendedCached(); + runZonedDateTimeForComponentsCompleteNoCache(); + runZonedDateTimeForComponentsCompleteCached(); runZonedExtraForEpochSecondsBasicNoCache(); runZonedExtraForEpochSecondsBasicCached(); runZonedExtraForEpochSecondsExtendedNoCache(); runZonedExtraForEpochSecondsExtendedCached(); + runZonedExtraForEpochSecondsCompleteNoCache(); + runZonedExtraForEpochSecondsCompleteCached(); runZonedExtraForComponentsBasicNoCache(); runZonedExtraForComponentsBasicCached(); runZonedExtraForComponentsExtendedNoCache(); runZonedExtraForComponentsExtendedCached(); + runZonedExtraForComponentsCompleteNoCache(); + runZonedExtraForComponentsCompleteCached(); + + runBasicRegistrarFindIndexForName(); + runBasicRegistrarFindIndexForIdBinary(); + runBasicRegistrarFindIndexForIdLinear(); + + runExtendedRegistrarFindIndexForName(); + runExtendedRegistrarFindIndexForIdBinary(); + runExtendedRegistrarFindIndexForIdLinear(); - runIndexForZoneName(); - runIndexForZoneIdBinary(); - runIndexForZoneIdLinear(); + runCompleteRegistrarFindIndexForName(); + runCompleteRegistrarFindIndexForIdBinary(); + runCompleteRegistrarFindIndexForIdLinear(); SERIAL_PORT_MONITOR.print(F("Iterations_per_run ")); SERIAL_PORT_MONITOR.println(COUNT); diff --git a/examples/AutoBenchmark/zone_registry.cpp b/examples/AutoBenchmark/basic_registry.cpp similarity index 98% rename from examples/AutoBenchmark/zone_registry.cpp rename to examples/AutoBenchmark/basic_registry.cpp index 9f2956187..b41beeeeb 100644 --- a/examples/AutoBenchmark/zone_registry.cpp +++ b/examples/AutoBenchmark/basic_registry.cpp @@ -3,14 +3,14 @@ // Arduino Nano. #include -#include "zone_registry.h" +#include "basic_registry.h" using namespace ace_time; //--------------------------------------------------------------------------- // Zone registry. Sorted by zoneId. //--------------------------------------------------------------------------- -const basic::ZoneInfo* const kBenchmarkZoneRegistry[kBenchmarkZoneRegistrySize] +const basic::ZoneInfo* const kBasicRegistry[kBasicRegistrySize] ACE_TIME_PROGMEM = { &zonedb::kZoneAsia_Kuala_Lumpur, // 0x014763c4, Asia/Kuala_Lumpur &zonedb::kZoneIndian_Cocos, // 0x021e86de, Indian/Cocos diff --git a/examples/AutoBenchmark/zone_registry.h b/examples/AutoBenchmark/basic_registry.h similarity index 56% rename from examples/AutoBenchmark/zone_registry.h rename to examples/AutoBenchmark/basic_registry.h index 794f0de94..8889462b7 100644 --- a/examples/AutoBenchmark/zone_registry.h +++ b/examples/AutoBenchmark/basic_registry.h @@ -2,13 +2,13 @@ // to 85 zones so that AutoBenchmark can fit inside the 32kB limit of an // Arduino Nano. -#ifndef AUTO_BENCHMARK_ZONE_REGISTRY_H -#define AUTO_BENCHMARK_ZONE_REGISTRY_H +#ifndef AUTO_BENCHMARK_BASIC_REGISTRY_H +#define AUTO_BENCHMARK_BASIC_REGISTRY_H #include -const uint16_t kBenchmarkZoneRegistrySize = 83; +const uint16_t kBasicRegistrySize = 83; extern const ace_time::basic::ZoneInfo* const - kBenchmarkZoneRegistry[kBenchmarkZoneRegistrySize]; + kBasicRegistry[kBasicRegistrySize]; #endif diff --git a/examples/AutoBenchmark/complete_registry.cpp b/examples/AutoBenchmark/complete_registry.cpp new file mode 100644 index 000000000..69f2dce50 --- /dev/null +++ b/examples/AutoBenchmark/complete_registry.cpp @@ -0,0 +1,99 @@ +// This file was copied from src/zonedb/zone_registry.cpp, then reduced +// to 85 zones so that AutoBenchmark can fit inside the 32kB limit of an +// Arduino Nano. + +#include +#include "complete_registry.h" + +using namespace ace_time; + +//--------------------------------------------------------------------------- +// Zone registry. Sorted by zoneId. +//--------------------------------------------------------------------------- +const complete::ZoneInfo* const kCompleteRegistry[kCompleteRegistrySize] + ACE_TIME_PROGMEM = { + &zonedbc::kZoneAsia_Kuala_Lumpur, // 0x014763c4, Asia/Kuala_Lumpur + &zonedbc::kZoneIndian_Cocos, // 0x021e86de, Indian/Cocos + &zonedbc::kZoneAmerica_Mazatlan, // 0x0532189e, America/Mazatlan + &zonedbc::kZoneAmerica_Guatemala, // 0x0c8259f7, America/Guatemala + &zonedbc::kZoneAmerica_Yellowknife, // 0x0f76c76f, America/Yellowknife + &zonedbc::kZoneAmerica_Sao_Paulo, // 0x1063bfc9, America/Sao_Paulo + &zonedbc::kZoneAmerica_Indiana_Vevay, // 0x10aca054, America/Indiana/Vevay + &zonedbc::kZoneAsia_Dhaka, // 0x14c07b8b, Asia/Dhaka + &zonedbc::kZoneAsia_Qatar, // 0x15a8330b, Asia/Qatar + &zonedbc::kZoneAmerica_Guayaquil, // 0x17e64958, America/Guayaquil + &zonedbc::kZoneAmerica_New_York, // 0x1e2a7654, America/New_York + &zonedbc::kZoneAsia_Ho_Chi_Minh, // 0x20f2d127, Asia/Ho_Chi_Minh + &zonedbc::kZonePacific_Wake, // 0x23416c2b, Pacific/Wake + &zonedbc::kZoneAmerica_Monterrey, // 0x269a1deb, America/Monterrey + &zonedbc::kZoneAmerica_Vancouver, // 0x2c6f6b1f, America/Vancouver + &zonedbc::kZoneAustralia_Hobart, // 0x32bf951a, Australia/Hobart + &zonedbc::kZoneAmerica_Cayenne, // 0x3c617269, America/Cayenne + &zonedbc::kZoneEurope_Athens, // 0x4318fa27, Europe/Athens + &zonedbc::kZoneIndian_Chagos, // 0x456f7c3c, Indian/Chagos + &zonedbc::kZoneAmerica_Chicago, // 0x4b92b5d4, America/Chicago + &zonedbc::kZoneAmerica_Asuncion, // 0x50ec79a6, America/Asuncion + &zonedbc::kZonePacific_Gambier, // 0x53720c3a, Pacific/Gambier + &zonedbc::kZoneAmerica_Jamaica, // 0x565dad6c, America/Jamaica + &zonedbc::kZonePacific_Marquesas, // 0x57ca7135, Pacific/Marquesas + &zonedbc::kZoneAsia_Jerusalem, // 0x5becd23a, Asia/Jerusalem + &zonedbc::kZoneEurope_London, // 0x5c6a84ae, Europe/London + &zonedbc::kZonePacific_Pago_Pago, // 0x603aebd0, Pacific/Pago_Pago + &zonedbc::kZoneEurope_Prague, // 0x65ee5d48, Europe/Prague + &zonedbc::kZoneAsia_Makassar, // 0x6aa21c85, Asia/Makassar + &zonedbc::kZoneAmerica_Dawson_Creek, // 0x6cf24e5b, America/Dawson_Creek + &zonedbc::kZoneAsia_Kolkata, // 0x72c06cd9, Asia/Kolkata + &zonedbc::kZoneAmerica_El_Salvador, // 0x752ad652, America/El_Salvador + &zonedbc::kZoneAmerica_Toronto, // 0x792e851b, America/Toronto + &zonedbc::kZoneIndian_Mauritius, // 0x7b09c02a, Indian/Mauritius + &zonedbc::kZoneAsia_Kuching, // 0x801b003b, Asia/Kuching + &zonedbc::kZoneAmerica_Atikokan, // 0x81b92098, America/Atikokan + &zonedbc::kZonePacific_Chuuk, // 0x8a090b23, Pacific/Chuuk + &zonedbc::kZonePacific_Nauru, // 0x8acc41ae, Pacific/Nauru + &zonedbc::kZonePacific_Kwajalein, // 0x8e216759, Pacific/Kwajalein + &zonedbc::kZoneAmerica_Detroit, // 0x925cfbc1, America/Detroit + &zonedbc::kZoneAmerica_Denver, // 0x97d10b2a, America/Denver + &zonedbc::kZoneAmerica_Belem, // 0x97da580b, America/Belem + &zonedbc::kZonePacific_Rarotonga, // 0x9981a3b0, Pacific/Rarotonga + &zonedbc::kZoneAsia_Baghdad, // 0x9ceffbed, Asia/Baghdad + &zonedbc::kZoneAfrica_Ndjamena, // 0x9fe09898, Africa/Ndjamena + &zonedbc::kZoneAmerica_Havana, // 0xa0e15675, America/Havana + &zonedbc::kZoneEurope_Oslo, // 0xa2c3fba1, Europe/Oslo + &zonedbc::kZoneEurope_Rome, // 0xa2c58fd7, Europe/Rome + &zonedbc::kZoneAmerica_Inuvik, // 0xa42189fc, America/Inuvik + &zonedbc::kZoneAmerica_Juneau, // 0xa6f13e2e, America/Juneau + &zonedbc::kZoneAustralia_Lord_Howe, // 0xa748b67d, Australia/Lord_Howe + &zonedbc::kZonePacific_Port_Moresby, // 0xa7ba7f68, Pacific/Port_Moresby + &zonedbc::kZoneAsia_Beirut, // 0xa7f3d5fd, Asia/Beirut + &zonedbc::kZoneAfrica_Nairobi, // 0xa87ab57e, Africa/Nairobi + &zonedbc::kZoneAsia_Brunei, // 0xa8e595f7, Asia/Brunei + &zonedbc::kZonePacific_Galapagos, // 0xa952f752, Pacific/Galapagos + &zonedbc::kZoneAmerica_La_Paz, // 0xaa29125d, America/La_Paz + &zonedbc::kZoneAmerica_Manaus, // 0xac86bf8b, America/Manaus + &zonedbc::kZoneAmerica_Merida, // 0xacd172d8, America/Merida + &zonedbc::kZoneEurope_Chisinau, // 0xad58aa18, Europe/Chisinau + &zonedbc::kZoneAmerica_Nassau, // 0xaedef011, America/Nassau + &zonedbc::kZoneEurope_Uzhgorod, // 0xb066f5d6, Europe/Uzhgorod + &zonedbc::kZoneAustralia_Broken_Hill, // 0xb06eada3, Australia/Broken_Hill + &zonedbc::kZoneAmerica_Paramaribo, // 0xb319e4c4, America/Paramaribo + &zonedbc::kZoneAmerica_Panama, // 0xb3863854, America/Panama + &zonedbc::kZoneAmerica_Los_Angeles, // 0xb7f7e8f2, America/Los_Angeles + &zonedbc::kZoneAmerica_Regina, // 0xb875371c, America/Regina + &zonedbc::kZoneAmerica_Halifax, // 0xbc5b7183, America/Halifax + &zonedbc::kZoneAsia_Riyadh, // 0xcd973d93, Asia/Riyadh + &zonedbc::kZoneAsia_Singapore, // 0xcf8581fa, Asia/Singapore + &zonedbc::kZoneAsia_Tehran, // 0xd1f02254, Asia/Tehran + &zonedbc::kZoneAfrica_Johannesburg, // 0xd5d157a0, Africa/Johannesburg + &zonedbc::kZoneEtc_UTC, // 0xd8e31abc, Etc/UTC + &zonedbc::kZoneEurope_Brussels, // 0xdee07337, Europe/Brussels + &zonedbc::kZoneAntarctica_Syowa, // 0xe330c7e1, Antarctica/Syowa + &zonedbc::kZoneMST7MDT, // 0xf2af9375, MST7MDT + &zonedbc::kZoneEurope_Gibraltar, // 0xf8e325fc, Europe/Gibraltar + &zonedbc::kZoneAmerica_Montevideo, // 0xfa214780, America/Montevideo + &zonedbc::kZoneEurope_Bucharest, // 0xfb349ec5, Europe/Bucharest + &zonedbc::kZoneEurope_Paris, // 0xfb4bc2a3, Europe/Paris + &zonedbc::kZoneEurope_Sofia, // 0xfb898656, Europe/Sofia + &zonedbc::kZoneAtlantic_Canary, // 0xfc23f2c2, Atlantic/Canary + &zonedbc::kZoneAmerica_Campo_Grande, // 0xfec3e7a6, America/Campo_Grande + +}; diff --git a/examples/AutoBenchmark/complete_registry.h b/examples/AutoBenchmark/complete_registry.h new file mode 100644 index 000000000..550af33ef --- /dev/null +++ b/examples/AutoBenchmark/complete_registry.h @@ -0,0 +1,14 @@ +// This file was copied from src/zonedb/zone_registry.cpp, then reduced +// to 85 zones so that AutoBenchmark can fit inside the 32kB limit of an +// Arduino Nano. + +#ifndef AUTO_BENCHMARK_COMPLETE_REGISTRY_H +#define AUTO_BENCHMARK_COMPLETE_REGISTRY_H + +#include + +const uint16_t kCompleteRegistrySize = 83; +extern const ace_time::complete::ZoneInfo* const + kCompleteRegistry[kCompleteRegistrySize]; + +#endif diff --git a/examples/AutoBenchmark/extended_registry.cpp b/examples/AutoBenchmark/extended_registry.cpp new file mode 100644 index 000000000..bd3c9e492 --- /dev/null +++ b/examples/AutoBenchmark/extended_registry.cpp @@ -0,0 +1,99 @@ +// This file was copied from src/zonedb/zone_registry.cpp, then reduced +// to 85 zones so that AutoBenchmark can fit inside the 32kB limit of an +// Arduino Nano. + +#include +#include "extended_registry.h" + +using namespace ace_time; + +//--------------------------------------------------------------------------- +// Zone registry. Sorted by zoneId. +//--------------------------------------------------------------------------- +const extended::ZoneInfo* const kExtendedRegistry[kExtendedRegistrySize] + ACE_TIME_PROGMEM = { + &zonedbx::kZoneAsia_Kuala_Lumpur, // 0x014763c4, Asia/Kuala_Lumpur + &zonedbx::kZoneIndian_Cocos, // 0x021e86de, Indian/Cocos + &zonedbx::kZoneAmerica_Mazatlan, // 0x0532189e, America/Mazatlan + &zonedbx::kZoneAmerica_Guatemala, // 0x0c8259f7, America/Guatemala + &zonedbx::kZoneAmerica_Yellowknife, // 0x0f76c76f, America/Yellowknife + &zonedbx::kZoneAmerica_Sao_Paulo, // 0x1063bfc9, America/Sao_Paulo + &zonedbx::kZoneAmerica_Indiana_Vevay, // 0x10aca054, America/Indiana/Vevay + &zonedbx::kZoneAsia_Dhaka, // 0x14c07b8b, Asia/Dhaka + &zonedbx::kZoneAsia_Qatar, // 0x15a8330b, Asia/Qatar + &zonedbx::kZoneAmerica_Guayaquil, // 0x17e64958, America/Guayaquil + &zonedbx::kZoneAmerica_New_York, // 0x1e2a7654, America/New_York + &zonedbx::kZoneAsia_Ho_Chi_Minh, // 0x20f2d127, Asia/Ho_Chi_Minh + &zonedbx::kZonePacific_Wake, // 0x23416c2b, Pacific/Wake + &zonedbx::kZoneAmerica_Monterrey, // 0x269a1deb, America/Monterrey + &zonedbx::kZoneAmerica_Vancouver, // 0x2c6f6b1f, America/Vancouver + &zonedbx::kZoneAustralia_Hobart, // 0x32bf951a, Australia/Hobart + &zonedbx::kZoneAmerica_Cayenne, // 0x3c617269, America/Cayenne + &zonedbx::kZoneEurope_Athens, // 0x4318fa27, Europe/Athens + &zonedbx::kZoneIndian_Chagos, // 0x456f7c3c, Indian/Chagos + &zonedbx::kZoneAmerica_Chicago, // 0x4b92b5d4, America/Chicago + &zonedbx::kZoneAmerica_Asuncion, // 0x50ec79a6, America/Asuncion + &zonedbx::kZonePacific_Gambier, // 0x53720c3a, Pacific/Gambier + &zonedbx::kZoneAmerica_Jamaica, // 0x565dad6c, America/Jamaica + &zonedbx::kZonePacific_Marquesas, // 0x57ca7135, Pacific/Marquesas + &zonedbx::kZoneAsia_Jerusalem, // 0x5becd23a, Asia/Jerusalem + &zonedbx::kZoneEurope_London, // 0x5c6a84ae, Europe/London + &zonedbx::kZonePacific_Pago_Pago, // 0x603aebd0, Pacific/Pago_Pago + &zonedbx::kZoneEurope_Prague, // 0x65ee5d48, Europe/Prague + &zonedbx::kZoneAsia_Makassar, // 0x6aa21c85, Asia/Makassar + &zonedbx::kZoneAmerica_Dawson_Creek, // 0x6cf24e5b, America/Dawson_Creek + &zonedbx::kZoneAsia_Kolkata, // 0x72c06cd9, Asia/Kolkata + &zonedbx::kZoneAmerica_El_Salvador, // 0x752ad652, America/El_Salvador + &zonedbx::kZoneAmerica_Toronto, // 0x792e851b, America/Toronto + &zonedbx::kZoneIndian_Mauritius, // 0x7b09c02a, Indian/Mauritius + &zonedbx::kZoneAsia_Kuching, // 0x801b003b, Asia/Kuching + &zonedbx::kZoneAmerica_Atikokan, // 0x81b92098, America/Atikokan + &zonedbx::kZonePacific_Chuuk, // 0x8a090b23, Pacific/Chuuk + &zonedbx::kZonePacific_Nauru, // 0x8acc41ae, Pacific/Nauru + &zonedbx::kZonePacific_Kwajalein, // 0x8e216759, Pacific/Kwajalein + &zonedbx::kZoneAmerica_Detroit, // 0x925cfbc1, America/Detroit + &zonedbx::kZoneAmerica_Denver, // 0x97d10b2a, America/Denver + &zonedbx::kZoneAmerica_Belem, // 0x97da580b, America/Belem + &zonedbx::kZonePacific_Rarotonga, // 0x9981a3b0, Pacific/Rarotonga + &zonedbx::kZoneAsia_Baghdad, // 0x9ceffbed, Asia/Baghdad + &zonedbx::kZoneAfrica_Ndjamena, // 0x9fe09898, Africa/Ndjamena + &zonedbx::kZoneAmerica_Havana, // 0xa0e15675, America/Havana + &zonedbx::kZoneEurope_Oslo, // 0xa2c3fba1, Europe/Oslo + &zonedbx::kZoneEurope_Rome, // 0xa2c58fd7, Europe/Rome + &zonedbx::kZoneAmerica_Inuvik, // 0xa42189fc, America/Inuvik + &zonedbx::kZoneAmerica_Juneau, // 0xa6f13e2e, America/Juneau + &zonedbx::kZoneAustralia_Lord_Howe, // 0xa748b67d, Australia/Lord_Howe + &zonedbx::kZonePacific_Port_Moresby, // 0xa7ba7f68, Pacific/Port_Moresby + &zonedbx::kZoneAsia_Beirut, // 0xa7f3d5fd, Asia/Beirut + &zonedbx::kZoneAfrica_Nairobi, // 0xa87ab57e, Africa/Nairobi + &zonedbx::kZoneAsia_Brunei, // 0xa8e595f7, Asia/Brunei + &zonedbx::kZonePacific_Galapagos, // 0xa952f752, Pacific/Galapagos + &zonedbx::kZoneAmerica_La_Paz, // 0xaa29125d, America/La_Paz + &zonedbx::kZoneAmerica_Manaus, // 0xac86bf8b, America/Manaus + &zonedbx::kZoneAmerica_Merida, // 0xacd172d8, America/Merida + &zonedbx::kZoneEurope_Chisinau, // 0xad58aa18, Europe/Chisinau + &zonedbx::kZoneAmerica_Nassau, // 0xaedef011, America/Nassau + &zonedbx::kZoneEurope_Uzhgorod, // 0xb066f5d6, Europe/Uzhgorod + &zonedbx::kZoneAustralia_Broken_Hill, // 0xb06eada3, Australia/Broken_Hill + &zonedbx::kZoneAmerica_Paramaribo, // 0xb319e4c4, America/Paramaribo + &zonedbx::kZoneAmerica_Panama, // 0xb3863854, America/Panama + &zonedbx::kZoneAmerica_Los_Angeles, // 0xb7f7e8f2, America/Los_Angeles + &zonedbx::kZoneAmerica_Regina, // 0xb875371c, America/Regina + &zonedbx::kZoneAmerica_Halifax, // 0xbc5b7183, America/Halifax + &zonedbx::kZoneAsia_Riyadh, // 0xcd973d93, Asia/Riyadh + &zonedbx::kZoneAsia_Singapore, // 0xcf8581fa, Asia/Singapore + &zonedbx::kZoneAsia_Tehran, // 0xd1f02254, Asia/Tehran + &zonedbx::kZoneAfrica_Johannesburg, // 0xd5d157a0, Africa/Johannesburg + &zonedbx::kZoneEtc_UTC, // 0xd8e31abc, Etc/UTC + &zonedbx::kZoneEurope_Brussels, // 0xdee07337, Europe/Brussels + &zonedbx::kZoneAntarctica_Syowa, // 0xe330c7e1, Antarctica/Syowa + &zonedbx::kZoneMST7MDT, // 0xf2af9375, MST7MDT + &zonedbx::kZoneEurope_Gibraltar, // 0xf8e325fc, Europe/Gibraltar + &zonedbx::kZoneAmerica_Montevideo, // 0xfa214780, America/Montevideo + &zonedbx::kZoneEurope_Bucharest, // 0xfb349ec5, Europe/Bucharest + &zonedbx::kZoneEurope_Paris, // 0xfb4bc2a3, Europe/Paris + &zonedbx::kZoneEurope_Sofia, // 0xfb898656, Europe/Sofia + &zonedbx::kZoneAtlantic_Canary, // 0xfc23f2c2, Atlantic/Canary + &zonedbx::kZoneAmerica_Campo_Grande, // 0xfec3e7a6, America/Campo_Grande + +}; diff --git a/examples/AutoBenchmark/extended_registry.h b/examples/AutoBenchmark/extended_registry.h new file mode 100644 index 000000000..60d762ef8 --- /dev/null +++ b/examples/AutoBenchmark/extended_registry.h @@ -0,0 +1,14 @@ +// This file was copied from src/zonedb/zone_registry.cpp, then reduced +// to 85 zones so that AutoBenchmark can fit inside the 32kB limit of an +// Arduino Nano. + +#ifndef AUTO_BENCHMARK_EXTENDED_REGISTRY_H +#define AUTO_BENCHMARK_EXTENDED_REGISTRY_H + +#include + +const uint16_t kExtendedRegistrySize = 83; +extern const ace_time::extended::ZoneInfo* const + kExtendedRegistry[kExtendedRegistrySize]; + +#endif diff --git a/src/ace_time/ZoneRegistrar.h b/src/ace_time/ZoneRegistrar.h index 1d937c825..1a27d8e9d 100644 --- a/src/ace_time/ZoneRegistrar.h +++ b/src/ace_time/ZoneRegistrar.h @@ -12,8 +12,15 @@ #include "../zoneinfo/brokers.h" // AutoBenchmark.ino -void runIndexForZoneIdBinary(); -void runIndexForZoneIdLinear(); +void runBasicRegistrarFindIndexForName(); +void runBasicRegistrarFindIndexForIdBinary(); +void runBasicRegistrarFindIndexForIdLinear(); +void runExtendedRegistrarFindIndexForName(); +void runExtendedRegistrarFindIndexForIdBinary(); +void runExtendedRegistrarFindIndexForIdLinear(); +void runCompleteRegistrarFindIndexForName(); +void runCompleteRegistrarFindIndexForIdBinary(); +void runCompleteRegistrarFindIndexForIdLinear(); // Tests class ZoneRegistrarTest_Sorted_isSorted; @@ -107,8 +114,15 @@ class ZoneRegistrarTemplate { } protected: - friend void ::runIndexForZoneIdBinary(); - friend void ::runIndexForZoneIdLinear(); + friend void ::runBasicRegistrarFindIndexForName(); + friend void ::runBasicRegistrarFindIndexForIdBinary(); + friend void ::runBasicRegistrarFindIndexForIdLinear(); + friend void ::runExtendedRegistrarFindIndexForName(); + friend void ::runExtendedRegistrarFindIndexForIdBinary(); + friend void ::runExtendedRegistrarFindIndexForIdLinear(); + friend void ::runCompleteRegistrarFindIndexForName(); + friend void ::runCompleteRegistrarFindIndexForIdBinary(); + friend void ::runCompleteRegistrarFindIndexForIdLinear(); friend class ::ZoneRegistrarTest_Sorted_isSorted; friend class ::ZoneRegistrarTest_Unsorted_isSorted; friend class ::ZoneRegistrarTest_Sorted_linearSearchById;