Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | {4617} fixed TRawUTF8List.LoadFromFile |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
641362ff2722039796dc4d2b79967ab9 |
User & Date: | ab 2018-06-13 21:00:00 |
2018-06-14
| ||
11:59 | {4618} tuned code for better FPC generated asm optimization check-in: 204393d2a4 user: ab tags: trunk | |
2018-06-13
| ||
21:00 | {4617} fixed TRawUTF8List.LoadFromFile check-in: 641362ff27 user: ab tags: trunk | |
12:44 | {4616} new EnumAllProcesses/EnumProcessName functions and TProcessInfo object - for low-level CPU/Process monitoring on Windows check-in: ebe1bc65d8 user: ab tags: trunk | |
Changes to SynCommons.pas.
9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 ..... 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 ..... 26483 26484 26485 26486 26487 26488 26489 26490 26491 26492 26493 26494 26495 26496 26497 26498 26499 ..... 58625 58626 58627 58628 58629 58630 58631 58632 58633 58634 58635 58636 58637 58638 58639 58640 58641 58642 58643 58644 58645 58646 58647 58648 58649 58650 58651 58652 58653 58654 58655 58656 58657 58658 58659 58660 58661 58662 58663 58664 58665 58666 58667 58668 58669 58670 58671 58672 58673 58674 58675 58676 58677 58678 58679 58680 58681 58682 58683 58684 58685 58686 58687 58688 58689 58690 ..... 65017 65018 65019 65020 65021 65022 65023 65024 65025 65026 65027 65028 65029 65030 65031 |
function GetCount: PtrInt; {$ifdef HASINLINE}inline;{$endif} procedure PutObject(Index: PtrInt; const Value: TObject); function GetName(Index: PtrInt): RawUTF8; function GetValue(const Name: RawUTF8): RawUTF8; procedure SetValue(const Name, Value: RawUTF8); function GetTextCRLF: RawUTF8; procedure SetTextCRLF(const Value: RawUTF8); procedure SetTextPtr(P: PUTF8Char; const Delimiter: RawUTF8); function GetListPtr: PPUtf8CharArray; function GetObjectPtr: PPointerArray; {$ifdef HASINLINE}inline;{$endif} procedure SetCaseSensitive(Value: boolean); virtual; public /// initialize the class instance // - by default, any associated Objects[] are just weak references // - also define CaseSensitive=true ................................................................................ // will emulate it for older Windows versions GetTickCount64: function: Int64; stdcall; /// similar to Windows sleep() API call, to be truly cross-platform // - it should have a millisecond resolution, and handle ms=0 as a switch to // another pending thread, i.e. under Windows will call SwitchToThread API procedure SleepHiRes(ms: cardinal); {$else MSWINDOWS} var /// emulate only some used fields of Windows' TSystemInfo SystemInfo: record // retrieved from libc's getpagesize() ................................................................................ and eax, dword ptr[@mask + ecx * 4] @smlo: setz al end; {$endif} {$ifdef MSWINDOWS} procedure FileTimeToInt64(const FT: TFileTime; out I64: Int64); {$ifdef HASINLINE}inline;{$endif} begin {$ifdef CPU64} // as recommended by MSDN to avoid dword alignment issue PInt64Rec(@I64)^.Lo := FT.dwLowDateTime; PInt64Rec(@I64)^.Hi := FT.dwHighDateTime; {$else} I64 := PInt64(@FT)^; {$endif} end; ................................................................................ end; end; end; end; procedure TRawUTF8List.SetText(const aText, Delimiter: RawUTF8); begin SetTextPtr(pointer(aText),Delimiter); end; procedure TRawUTF8List.LoadFromFile(const FileName: TFileName); var Map: TMemoryMap; P: pointer; begin if Map.Map(FileName) then try if Map.Size<>0 then begin if TextFileKind(Map)=isUTF8 then // ignore UTF-8 BOM P := Map.Buffer+3 else P := Map.Buffer; SetTextPtr(P,#13#10); end; finally Map.UnMap; end; end; procedure TRawUTF8List.SetTextPtr(P: PUTF8Char; const Delimiter: RawUTF8); var DelimLen: PtrInt; DelimFirst: AnsiChar; PBeg, DelimNext: PUTF8Char; Line: RawUTF8; begin DelimLen := length(Delimiter); BeginUpdate; Clear; if (P<>nil) and (DelimLen>0) then begin DelimFirst := Delimiter[1]; DelimNext := PUTF8Char(pointer(Delimiter))+1; repeat PBeg := P; while P^<>#0 do begin if (P^=DelimFirst) and CompareMem(P+1,DelimNext,DelimLen-1) then break; inc(P); end; SetString(Line,PBeg,P-PBeg); AddObject(Line,nil); if P^=#0 then break; inc(P,DelimLen); until P^=#0; end; EndUpdate; end; procedure TRawUTF8List.SetTextCRLF(const Value: RawUTF8); begin SetTextPtr(pointer(Value),#13#10); end; procedure TRawUTF8List.SetValue(const Name, Value: RawUTF8); var i: PtrInt; begin i := IndexOfName(Name); if i<0 then ................................................................................ exit; FileTimeToInt64(ftidl,sidl); FileTimeToInt64(ftkrn,skrn); FileTimeToInt64(ftusr,susr); fDiffIdle := sidl-fSysPrevIdle; fDiffKernel := skrn-fSysPrevKernel; fDiffUser := susr-fSysPrevUser; fDiffTotal := fDiffKernel+fDiffUser; // kernel time also includes idle dec(fDiffKernel, fDiffIdle); fSysPrevIdle := sidl; fSysPrevKernel := skrn; fSysPrevUser := susr; end; function TProcessInfo.PerProcess(PID: cardinal; Now: PDateTime; |
| > > > > > < < > | | | | > > | | > | | | | | | | | |
9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 ..... 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 ..... 26488 26489 26490 26491 26492 26493 26494 26495 26496 26497 26498 26499 26500 26501 26502 26503 ..... 58629 58630 58631 58632 58633 58634 58635 58636 58637 58638 58639 58640 58641 58642 58643 58644 58645 58646 58647 58648 58649 58650 58651 58652 58653 58654 58655 58656 58657 58658 58659 58660 58661 58662 58663 58664 58665 58666 58667 58668 58669 58670 58671 58672 58673 58674 58675 58676 58677 58678 58679 58680 58681 58682 58683 58684 58685 58686 58687 58688 58689 58690 58691 58692 58693 58694 58695 58696 58697 ..... 65024 65025 65026 65027 65028 65029 65030 65031 65032 65033 65034 65035 65036 65037 65038 |
function GetCount: PtrInt; {$ifdef HASINLINE}inline;{$endif} procedure PutObject(Index: PtrInt; const Value: TObject); function GetName(Index: PtrInt): RawUTF8; function GetValue(const Name: RawUTF8): RawUTF8; procedure SetValue(const Name, Value: RawUTF8); function GetTextCRLF: RawUTF8; procedure SetTextCRLF(const Value: RawUTF8); procedure SetTextPtr(P,PEnd: PUTF8Char; const Delimiter: RawUTF8); function GetListPtr: PPUtf8CharArray; function GetObjectPtr: PPointerArray; {$ifdef HASINLINE}inline;{$endif} procedure SetCaseSensitive(Value: boolean); virtual; public /// initialize the class instance // - by default, any associated Objects[] are just weak references // - also define CaseSensitive=true ................................................................................ // will emulate it for older Windows versions GetTickCount64: function: Int64; stdcall; /// similar to Windows sleep() API call, to be truly cross-platform // - it should have a millisecond resolution, and handle ms=0 as a switch to // another pending thread, i.e. under Windows will call SwitchToThread API procedure SleepHiRes(ms: cardinal); /// low-level wrapper to get the 64-bit value from a TFileTime // - as recommended by MSDN to avoid dword alignment issue procedure FileTimeToInt64(const FT: TFileTime; out I64: Int64); {$ifdef HASINLINE}inline;{$endif} {$else MSWINDOWS} var /// emulate only some used fields of Windows' TSystemInfo SystemInfo: record // retrieved from libc's getpagesize() ................................................................................ and eax, dword ptr[@mask + ecx * 4] @smlo: setz al end; {$endif} {$ifdef MSWINDOWS} procedure FileTimeToInt64(const FT: TFileTime; out I64: Int64); begin {$ifdef CPU64} PInt64Rec(@I64)^.Lo := FT.dwLowDateTime; PInt64Rec(@I64)^.Hi := FT.dwHighDateTime; {$else} I64 := PInt64(@FT)^; {$endif} end; ................................................................................ end; end; end; end; procedure TRawUTF8List.SetText(const aText, Delimiter: RawUTF8); begin SetTextPtr(pointer(aText),PUTF8Char(pointer(aText))+length(aText),Delimiter); end; procedure TRawUTF8List.LoadFromFile(const FileName: TFileName); var Map: TMemoryMap; P: PUTF8Char; begin if Map.Map(FileName) then try if Map.Size<>0 then begin if TextFileKind(Map)=isUTF8 then begin // ignore UTF-8 BOM P := pointer(Map.Buffer+3); SetTextPtr(P,P+Map.Size-3,#13#10); end else begin P := pointer(Map.Buffer); SetTextPtr(P,P+Map.Size,#13#10); end; end; finally Map.UnMap; end; end; procedure TRawUTF8List.SetTextPtr(P,PEnd: PUTF8Char; const Delimiter: RawUTF8); var DelimLen: PtrInt; DelimFirst: AnsiChar; PBeg, DelimNext: PUTF8Char; Line: RawUTF8; begin DelimLen := length(Delimiter); BeginUpdate; Clear; if (P<>nil) and (DelimLen>0) and (P<PEnd) then begin DelimFirst := Delimiter[1]; DelimNext := PUTF8Char(pointer(Delimiter))+1; repeat PBeg := P; while P<PEnd do begin if (P^=DelimFirst) and CompareMemFixed(P+1,DelimNext,DelimLen-1) then break; inc(P); end; SetString(Line,PBeg,P-PBeg); AddObject(Line,nil); if P>=PEnd then break; inc(P,DelimLen); until P>=PEnd; end; EndUpdate; end; procedure TRawUTF8List.SetTextCRLF(const Value: RawUTF8); begin SetText(Value,#13#10); end; procedure TRawUTF8List.SetValue(const Name, Value: RawUTF8); var i: PtrInt; begin i := IndexOfName(Name); if i<0 then ................................................................................ exit; FileTimeToInt64(ftidl,sidl); FileTimeToInt64(ftkrn,skrn); FileTimeToInt64(ftusr,susr); fDiffIdle := sidl-fSysPrevIdle; fDiffKernel := skrn-fSysPrevKernel; fDiffUser := susr-fSysPrevUser; fDiffTotal := fDiffKernel+fDiffUser; // kernel time also includes idle time dec(fDiffKernel, fDiffIdle); fSysPrevIdle := sidl; fSysPrevKernel := skrn; fSysPrevUser := susr; end; function TProcessInfo.PerProcess(PID: cardinal; Now: PDateTime; |
Changes to SynopseCommit.inc.
1 |
'1.18.4616'
|
| |
1 |
'1.18.4617'
|