Changeset 846 for trunk/dll/comp.c
- Timestamp:
- Sep 27, 2007, 11:16:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r841 r846 36 36 20 Aug 07 SHL Revert to DosSleep(0) 37 37 20 Aug 07 SHL Use GetMSecTimer for timing 38 20 Aug 07 SHL A few more speed up tweaks. Some experimental timing code 38 39 26 Aug 07 GKY DosSleep(1) in loops changed to (0) 40 27 Sep 07 SHL Correct ULONGLONG size formatting 39 41 40 42 ***********************************************************************/ … … 121 123 strcpy(enddir, pffb->achName); 122 124 if (!(pffb->attrFile & FILE_DIRECTORY)) 125 // 27 Sep 07 SHL fixme to use CommaFmtULL 123 126 fprintf(fp, 124 "\"%s\",%u,%l u,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",127 "\"%s\",%u,%llu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n", 125 128 mask, 126 129 enddir - mask, … … 132 135 pffb->ftimeLastWrite.minutes, 133 136 pffb->ftimeLastWrite.twosecs, 134 pffb->attrFile, (pffb->cbList > 4) ? (pffb->cbList / 2) : 0); 137 pffb->attrFile, 138 pffb->cbList > 4 ? pffb->cbList / 2 : 0); 135 139 // Skip . and .. 136 140 else if (recurse && … … 372 376 373 377 case WM_DESTROY: 374 DosSleep(50); //05 Aug 07 GKY 100378 DosSleep(50); // 05 Aug 07 GKY 100 375 379 break; 376 380 } … … 482 486 else 483 487 cmp->cmp->totalright--; 484 DosSleep(0); //8-26-07 GKY 1488 DosSleep(0); // 8-26-07 GKY 1 485 489 } 486 490 break; … … 750 754 return; 751 755 } 756 757 // DbgMsg(pszSrcFile, __LINE__, "FillDirList start %s", str); 752 758 753 759 maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); … … 816 822 817 823 DosFindClose(hDir); 818 DosSleep( 1);824 DosSleep(0); 819 825 } 820 826 … … 826 832 free(maskstr); 827 833 free(pffbArray); 834 835 // DbgMsg(pszSrcFile, __LINE__, "FillDirList finish %s", str); 828 836 } 829 837 … … 836 844 837 845 return stricmp(fl1->fname, fl2->fname); 846 } 847 848 // 20 Aug 07 SHL experimental fixme 849 850 typedef struct { 851 // Caller must init 852 UINT sleepTime; // How long to sleep 853 UINT interval; // How often to sleep 854 // Owned by SleepIfNeeded 855 UINT modulo; // How often to call GetMSecTimer 856 UINT cntr; // Call counter 857 ULONG lastMSec; // Last time DosSleep invoked 858 } SLEEP_DESC; 859 860 VOID SleepIfNeeded(BOOL id, UINT interval, UINT sleepTime) 861 { 862 static ULONG lastMSec[10]; 863 static UINT cntr; 864 static UINT modulo = 32; 865 BOOL yes = ++cntr >= modulo; 866 867 if (yes) { 868 ULONG newMSec = GetMSecTimer(); 869 // 1st time will have large difference, but don't care 870 ULONG diff = newMSec - lastMSec[id]; 871 cntr = 0; 872 yes = diff >= interval; 873 // Try to tune modulo counter to approx 12% error 874 if (yes) { 875 lastMSec[id] = newMSec; 876 if (diff >= interval + (interval / 8) && modulo > 0) 877 modulo--; 878 } 879 else { 880 if (diff < interval - (interval / 8)) 881 modulo++; 882 } 883 DosSleep(sleepTime); 884 } 838 885 } 839 886 … … 847 894 BOOL notified = FALSE; 848 895 896 #if 0 849 897 ULONG lastMSec = GetMSecTimer(); 850 898 ULONG ul; 899 #endif 851 900 852 901 HWND hwndLeft, hwndRight; … … 858 907 _endthread(); 859 908 } 909 910 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread enter"); 860 911 861 912 DosError(FERR_DISABLEHARDERR); … … 873 924 INT l; 874 925 INT r; 875 U LONGcntr;926 UINT cntr; 876 927 FILELIST **filesl = NULL; 877 928 FILELIST **filesr = NULL; … … 916 967 if (filesl) 917 968 qsort(filesl, numfilesl, sizeof(CHAR *), CompNames); 969 970 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesl"); 918 971 919 972 // Build list of all files in right directory … … 997 1050 if (p) { 998 1051 p++; 1052 // 27 Sep 07 SHL fixme to do ULONGLONG conversion 999 1053 fb4.cbFile = atol(p); 1000 1054 p = strchr(p, ','); … … 1062 1116 qsort(filesr, numfilesr, sizeof(CHAR *), CompNames); 1063 1117 1118 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesr"); 1119 1064 1120 // We now have two lists of files, both sorted. 1065 1121 // Count total number of container entries required on each side … … 1115 1171 1116 1172 if (recsNeeded) { 1173 1174 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filling"); 1117 1175 1118 1176 pcil = pcilFirst; … … 1324 1382 DosSleep(0); 1325 1383 cntr++; 1326 #else 1327 if ((cntr++ % 500) == 0) { 1384 #endif 1385 #if 0 // 20 Aug 07 SHL 1386 if (cntr++ % 256 == 0) { 1328 1387 ul = GetMSecTimer(); 1329 if (ul - lastMSec >= 1000) {1388 if (ul - lastMSec >= 200) { 1330 1389 lastMSec = ul; 1331 1390 DosSleep(1); 1332 1391 } 1333 1392 } 1393 #endif 1394 #if 1 // 20 Aug 07 SHL 1395 SleepIfNeeded(0, 500, 1); 1334 1396 #endif 1335 1397 … … 1381 1443 cmp->cmp->totalright = numfilesr; 1382 1444 1445 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filled"); 1446 1383 1447 } // if recsNeeded 1384 1448 1385 1449 Deselect(hwndLeft); 1386 1450 Deselect(hwndRight); 1451 1452 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread deselected"); 1387 1453 1388 1454 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID)) 1389 1455 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID); 1390 1456 notified = TRUE; 1457 1458 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread FILLED posted"); 1391 1459 1392 1460 if (filesl) … … 1404 1472 free(cmp); 1405 1473 DosPostEventSem(CompactSem); 1474 1475 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread exit"); 1406 1476 } 1407 1477 … … 1409 1479 #define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR)) 1410 1480 #define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR)) 1481 1482 // 20 Aug 07 SHL fixme experimental 1483 1484 BOOL NeedGUIUpdate(BOOL id) 1485 { 1486 static ULONG lastMSec[10]; 1487 static UINT cntr; 1488 static UINT modulo = 32; 1489 BOOL yes = ++cntr >= modulo; 1490 1491 if (yes) { 1492 ULONG newMSec = GetMSecTimer(); 1493 // 1st time will have large difference, but don't care 1494 ULONG diff = newMSec - lastMSec[id]; 1495 cntr = 0; 1496 yes = diff >= 500; 1497 // Try to tune modulo counter to 10% error 1498 if (yes) { 1499 lastMSec[id] = newMSec; 1500 if (diff >= 550 && modulo > 0) 1501 modulo--; 1502 } 1503 else { 1504 if (diff < 450) 1505 modulo++; 1506 } 1507 } 1508 return yes; 1509 } 1411 1510 1412 1511 //=== CompareDlgProc() Compare directories dialog procedure === … … 1621 1720 CHAR s[81]; 1622 1721 1722 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED enter"); 1723 1623 1724 cmp->filling = FALSE; 1624 1725 WinEnableWindow(hwndLeft, TRUE); … … 1670 1771 else 1671 1772 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT)); 1773 1774 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED exit"); 1775 1672 1776 } 1673 1777 break; … … 1848 1952 } 1849 1953 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR) { 1850 if (WinIsWindowEnabled(hwndLeft) || !(cmp->selleft % 50)) { 1954 // if (WinIsWindowEnabled(hwndLeft) || !(cmp->selleft % 50)) { 1955 if (WinIsWindowEnabled(hwndLeft) || NeedGUIUpdate(0)) { 1851 1956 sprintf(s, " %d", cmp->selleft); 1852 1957 WinSetDlgItemText(hwnd, COMP_SELLEFT, s); … … 1854 1959 } 1855 1960 else { 1856 if (WinIsWindowEnabled(hwndRight) || !(cmp->selright % 50)) { 1961 // if (WinIsWindowEnabled(hwndRight) || !(cmp->selright % 50)) { 1962 if (WinIsWindowEnabled(hwndRight) || NeedGUIUpdate(1)) { 1857 1963 sprintf(s, " %d", cmp->selright); 1858 1964 WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
Note:
See TracChangeset
for help on using the changeset viewer.