commit f43bf575f2eeceec2598888950c9aee8104c63fb
Author: Francois Gouget <fgouget@codeweavers.com>
Date:   Wed Jul 14 17:48:55 2021 +0200

    DEBUG Trace the VARIANT_GetLocalisedNumberChars() run time.

diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c
index 89b35775053..806e8fd2b33 100644
--- a/dlls/kernelbase/locale.c
+++ b/dlls/kernelbase/locale.c
@@ -1012,7 +1012,7 @@ static INT get_registry_locale_info( const struct registry_value *registry_value
         ret = RegQueryValueExW( intl_key, registry_value->name, NULL, NULL, (BYTE *)buffer, &size );
         if (!ret)
         {
-            if (buffer && (registry_cache[index] = HeapAlloc( GetProcessHeap(), 0, size + sizeof(WCHAR) )))
+            if (01 && buffer && (registry_cache[index] = HeapAlloc( GetProcessHeap(), 0, size + sizeof(WCHAR) )))
             {
                 memcpy( registry_cache[index], buffer, size );
                 registry_cache[index][size / sizeof(WCHAR)] = 0;
diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c
index e4993de75a5..96e80ae9eff 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -1515,6 +1515,8 @@ HRESULT WINAPI VarUdateFromDate(DATE dateIn, ULONG dwFlags, UDATE *lpUdate)
     if (buff[0]) lpChars->name = buff[0]; \
   TRACE("lcid 0x%x, " #name "=%d '%c'\n", lcid, lpChars->name, lpChars->name)
 
+static int cache = 0;
+
 /* Get the valid number characters for an lcid */
 static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID lcid, DWORD dwFlags)
 {
@@ -1530,8 +1532,13 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID
 
   /* Asking for default locale entries is very expensive: It is a registry
      server call. So cache one locally, as Microsoft does it too */
-  if(lcid == lastLcid && dwFlags == lastFlags)
+  if(cache && lcid == lastLcid && dwFlags == lastFlags)
   {
+    if (cache == 1)
+    {
+        FIXME("using cached data lctype=%x lcid=%x dwFlags=%x\n", lctype, lcid, dwFlags);
+        cache++;
+    }
     memcpy(lpChars, &lastChars, sizeof(defaultChars));
     LeaveCriticalSection(&cache_cs);
     return;
@@ -1557,9 +1564,12 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID
   TRACE("lcid 0x%x, cCurrencyLocal=%d,%d %s\n", lcid, lpChars->cCurrencyLocal,
         lpChars->cCurrencyLocal2, wine_dbgstr_w(buff));
 
-  memcpy(&lastChars, lpChars, sizeof(defaultChars));
-  lastLcid = lcid;
-  lastFlags = dwFlags;
+  if (cache)
+  {
+    memcpy(&lastChars, lpChars, sizeof(defaultChars));
+    lastLcid = lcid;
+    lastFlags = dwFlags;
+  }
   LeaveCriticalSection(&cache_cs);
 }
 
@@ -1616,8 +1626,36 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
   int iMaxDigits = ARRAY_SIZE(rgbTmp);
   int cchUsed = 0;
   OLECHAR cDigitSeparator2;
+  static int timed = 0;
 
   TRACE("(%s,%d,0x%08x,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig);
+  if (!timed)
+  {
+      DWORD c, l, i;
+      LCID lcids[] = {LOCALE_USER_DEFAULT,
+                      MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),
+                      MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH),SORT_DEFAULT),
+                      MAKELCID(MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN),SORT_DEFAULT)};
+      for (c = 0; c <= 1; c++)
+      {
+          for (l = 0; l < ARRAY_SIZE(lcids); l++)
+          {
+              DWORD start = GetTickCount();
+              cache = c;
+              for (i = 0; i < 1000000; i++)
+                  VARIANT_GetLocalisedNumberChars(&chars, lcids[l], LOCALE_NOUSEROVERRIDE);
+              FIXME("GetLocalisedNumberChars(lcid=%x,NOUSEROVERRIDE,cache=%d) took %d ns\n", lcids[l], cache, (GetTickCount() - start) * 1000000 / i);
+
+              start = GetTickCount();
+              cache = c;
+              for (i = 0; i < 1000000; i++)
+                  VARIANT_GetLocalisedNumberChars(&chars, lcids[l], 0);
+              FIXME("GetLocalisedNumberChars(lcid=%x,0,cache=%d) took %d ns\n", lcids[l], cache, (GetTickCount() - start) * 1000000 / i);
+          }
+      }
+      cache = 1;
+      timed = 1;
+  }
 
   if (!pNumprs || !rgbDig)
     return E_INVALIDARG;
