logo.png
mORMot2 API Reference

mormot.core.perf.pas unit

Purpose: Framework Core Performance and Monitoring Classes
- this unit is a part of the Open Source Synopse mORMot framework 2, licensed under a MPL/GPL/LGPL three license - see LICENSE.md

1.1. Units used in the mormot.core.perf unit

Unit NameDescription
mormot.core.baseFramework Core Shared Types and RTL-like Functions
mormot.core.dataFramework Core Low-Level Data Processing Functions
mormot.core.datetimeFramework Core Low-Level Date and Time Support
mormot.core.jsonFramework Core Low-Level JSON Processing
mormot.core.logFramework Core Logging
mormot.core.osFramework Core Low-Level Wrappers to the Operating-System API
mormot.core.rttiFramework Core Low-Level Cross-Compiler RTTI Definitions
mormot.core.textFramework Core Low-Level Text Processing
mormot.core.unicodeFramework Core Low-Level Unicode UTF-8 UTF-16 Ansi Conversion
mormot.core.variantsFramework Core Low-Level Variants / TDocVariant process
mormot.lib.staticLow-level definitions needed to link static binaries

1.2. mormot.core.perf class hierarchy

TSynPersistentRWLightLockTSystemUseTSynPersistentLockTSynMonitorUsageTSynPersistentTSynMonitorTimeTSynMonitorSizeParentTSynMonitorOneTimeTSynMonitorMemoryTSynMonitorDiskTSynMonitorTSynMonitorThroughputTSynMonitorSizeTSynMonitorOneSizeTSynMonitorWithSizeTSynMonitorInputOutputTSynMonitorServerTSynInterfacedObjectTSynFpuExceptionTObjectTSynMonitorUsageIDTPrecisionTimerTInterfacedObjectTLocalPrecisionTimerIInterfaceILocalPrecisionTimer
mormot.core.perf class hierarchy

1.3. Objects implemented in the mormot.core.perf unit

ObjectsDescription
ILocalPrecisionTimerInterface to a reference counted high resolution timer instance
TLocalPrecisionTimerReference counted high resolution timer (for accurate speed statistics)
TPrecisionTimerHigh resolution timer (for accurate speed statistics)
TSmbiosBatteryPortable Battery (Type 22) structure
TSmbiosBiosBIOS Information (Type 0) structure
TSmbiosBoardBaseboard (or Module) Information (Type 2) structure (m)
TSmbiosCacheCache Information (Type 7) structure
TSmbiosChassisSystem Enclosure or Chassis (Type 3) structure
TSmbiosConnectorPort Connector Information (Type 8) structure
TSmbiosInfoHigh-Level Decoded SMBIOS Information
TSmbiosMemoryMemory Device (Type 17) structure
TSmbiosMemoryArrayPhysical Memory Array (Type 16) structure
TSmbiosPointingDeviceBuilt-in Pointing Device (Type 21) structure
TSmbiosProcessorProcessor Information (Type 4) structure
TSmbiosSlotSystem Slot (Type 9) structure
TSmbiosSystemSystem Information (Type 1) structure
TSynFpuExceptionA simple class which will set FPU exception flags for a code block
TSynMonitorA generic value object able to handle any task / process statistic
TSynMonitorDiskValue object able to gather information about a system drive
TSynMonitorInputOutputHandle generic process statistic with a incoming and outgoing processing data size and bandwitdh
TSynMonitorMemoryValue object able to gather information about the current system memory
TSynMonitorOneSizeAble to serialize any immediate size as bytes number
TSynMonitorOneTimeAble to serialize any immediate timing as raw micro-seconds number or text
TSynMonitorServerCould monitor a standard Server
TSynMonitorSizeAble to serialize any cumulative size as bytes number
TSynMonitorThroughputAble to serialize any bandwidth as bytes count per second
TSynMonitorTimeAble to serialize any cumulative timing as raw micro-seconds number or text
TSynMonitorUsageAbstract class to track, compute and store TSynMonitor detailed statistics
TSynMonitorUsageIDHow the TSynMonitorUsage storage IDs are computed
TSynMonitorUsageTrackOne class instance entry, as registered by TSynMonitorUsage.Track
TSynMonitorUsageTrackPropOne class property entry, as registered by TSynMonitorUsage.Track
TSynMonitorWithSizeHandle generic process statistic with a processing data size and bandwitdh
TSystemUseMonitor CPU and RAM usage of one or several processes
TSystemUseProcessInternal storage of CPU and RAM usage for one process

1.3.1. TPrecisionTimer

TPrecisionTimer = object(TObject)

High resolution timer (for accurate speed statistics)


function ByCount(Count: QWord): TShort16;

Compute the time elapsed by count, with appened time resolution (us,ms,s)


function FromExternalQueryPerformanceCounters(const CounterDiff: QWord): QWord;

Delphi 2007 is buggy as hell low-level method to force values settings to allow thread safe timing
- by default, this timer is not thread safe: you can use this method to set the timing values from manually computed performance counters
- the caller should also use a mutex to prevent from race conditions: see e.g. TSynMonitor.FromExternalQueryPerformanceCounters implementation
- returns the time elapsed, in micro seconds (i.e. LastTime value)
- warning: Start, Stop, Pause and Resume methods are then disallowed


function LastTime: TShort16;

Textual representation of last process timing after counter stopped
- Time returns a total elapsed time, whereas this method only returns the latest resumed time
- with appened time resolution (us,ms,s) - from MicroSecToString()
- not to be used in normal code, but e.g. for custom performance analysis


function PerSec(const Count: QWord): QWord;

Compute the per second count


function ProfileCurrentMethod: IUnknown;

Resume a paused timer until the method ends
- will internally create a TInterfaceObject class to let the compiler generate a try..finally block as expected to call Pause at method ending
- is therefore very convenient to have consistent Resume/Pause calls
- for proper use, expect TPrecisionTimer to be initialized to 0 before execution (e.g. define it as a protected member of a class)
- typical use is to declare a fTimeElapsed: TPrecisionTimer protected member, then call fTimeElapsed.ProfileCurrentMethod at the beginning of all process expecting some timing, then log/save fTimeElapsed.Stop content
- FPC TIP: result should be assigned to a local variable of IUnknown type


function SizePerSec(Size: QWord): ShortString;

Returns e.g. '16.9 MB in 102.20ms i.e. 165.5 MB/s'


function Started: boolean;

Check if Start/Resume were called at least once


function Stop: TShort16;

Stop the timer, returning the total time elapsed as text
- with appended time resolution (us,ms,s) - from MicroSecToString()
- is just a wrapper around Pause + Time
- you can call Resume to continue adding time to this timer


function StopInMicroSec: TSynMonitorTotalMicroSec;

Stop the timer, returning the total time elapsed as microseconds
- is just a wrapper around Pause + Time
- you can call Resume to continue adding time to this timer


function Time: TShort16;

Textual representation of total time elapsed
- with appened time resolution (us,ms,s) - from MicroSecToString()
- not to be used in normal code (which could rather call the Stop method), but e.g. for custom performance analysis


procedure FromExternalMicroSeconds(const MicroSeconds: QWord);

Low-level method to force values settings to allow thread safe timing
- by default, this timer is not thread safe: you can use this method to set the timing values from manually computed performance counters
- the caller should also use a mutex to prevent from race conditions: see e.g. TSynMonitor.FromExternalMicroSeconds implementation
- warning: Start, Stop, Pause and Resume methods are then disallowed


procedure Init;

Initialize the timer
- will fill all internal state with 0
- not necessary e.g. if TPrecisionTimer is defined as a class field


procedure Pause;

Stop the timer, ready to continue its time measurement via Resume
- will also compute the global Time value
- do nothing if no previous Start/Resume call is pending


procedure Resume;

Resume a paused timer, or start an initialized timer
- do nothing if no timer has been initialized or paused just before
- if the previous method called was Init, will act like Start
- if the previous method called was Pause, it will continue counting


procedure Start(CurrentMicroSeconds: Int64); overload;

Initialize and start the high resolution timer with a supplied timestamp
- if CurrentMicroSeconds is 0, will call QueryPerformanceMicroSeconds()


procedure Start; overload;

Initialize and start the high resolution timer
- similar to Init + Resume


property LastTimeInMicroSec: TSynMonitorOneMicroSec read fLastTime write fLastTime;

Timing in micro seconds of the last process
- not to be used in normal code, but e.g. for custom performance analysis


property PauseCount: TSynMonitorCount read fPauseCount;

How many times the Pause method was called, i.e. the number of tasks processeed


property TimeInMicroSec: TSynMonitorTotalMicroSec read fTime write fTime;

Time elapsed in micro seconds after counter stopped
- not to be used in normal code, but e.g. for custom performance analysis


1.3.2. ILocalPrecisionTimer

ILocalPrecisionTimer = interface(IInterface)

Interface to a reference counted high resolution timer instance
- implemented by TLocalPrecisionTimer


function ByCount(Count: cardinal): RawUtf8;

Compute the time elapsed by count, with appened time resolution (us,ms,s)


function PerSec(Count: cardinal): cardinal;

Compute the per second count


function Stop: TShort16;

Stop the timer, returning the time elapsed, with appened time resolution (us,ms,s)


procedure Pause;

Stop the timer, ready to continue its time measure


procedure Resume;

Resume a paused timer, or start it if it hasn't be started


procedure Start;

Start the high resolution timer


1.3.3. TLocalPrecisionTimer

TLocalPrecisionTimer = class(TInterfacedObject)

Reference counted high resolution timer (for accurate speed statistics)
- since TPrecisionTimer shall be 32-bit aligned, you can use this class to initialize a local auto-freeing ILocalPrecisionTimer variable on stack
- to be used as such:

 var Timer: ILocalPrecisionTimer;
  (...)
   Timer := TLocalPrecisionTimer.Create;
   Timer.Start;
  (...)

constructor CreateAndStart;

Initialize the instance, and start the high resolution timer


function ByCount(Count: cardinal): RawUtf8;

Compute the time elapsed by count, with appened time resolution (us,ms,s)


function PerSec(Count: cardinal): cardinal;

Compute the per second count


function Stop: TShort16;

Stop the timer, returning the time elapsed, with appened time resolution (us,ms,s)


procedure Pause;

Stop the timer, ready to continue its time measure


procedure Resume;

Resume a paused timer, or start the timer


procedure Start;

Start the high resolution timer


1.3.4. TSynMonitorTime

TSynMonitorTime = class(TSynPersistent)

Able to serialize any cumulative timing as raw micro-seconds number or text
- "cumulative" time would add each process value, e.g. SOA methods execution


function PerSecond(const Count: QWord): QWord;

Compute a number per second, of the current value


property MicroSec: TSynMonitorTotalMicroSec read fMicroSeconds write fMicroSeconds;

Delphi 2007 is buggy as hell micro seconds time elapsed, as raw number


property Text: TShort16 read GetAsText;

Micro seconds time elapsed, as '... us-ns-ms-s' text


1.3.5. TSynMonitorOneTime

TSynMonitorOneTime = class(TSynPersistent)

Able to serialize any immediate timing as raw micro-seconds number or text
- "immediate" size won't accumulate, i.e. may be e.g. last process time


function PerSecond(const Count: QWord): QWord;

Compute a number per second, of the current value


property MicroSec: TSynMonitorOneMicroSec read fMicroSeconds write fMicroSeconds;

Delphi 2007 is buggy as hell micro seconds time elapsed, as raw number


property Text: TShort16 read GetAsText;

Micro seconds time elapsed, as '... us-ns-ms-s' text


1.3.6. TSynMonitorSize

TSynMonitorSize = class(TSynMonitorSizeParent)

Able to serialize any cumulative size as bytes number
- "cumulative" time would add each process value, e.g. global IO consumption


property Bytes: TSynMonitorTotalBytes read fBytes write fBytes;

Number of bytes, as raw number


property Text: TShort16 read GetAsText;

Number of bytes, as '... B-KB-MB-GB' text


1.3.7. TSynMonitorOneSize

TSynMonitorOneSize = class(TSynMonitorSizeParent)

Able to serialize any immediate size as bytes number
- "immediate" size won't accumulate, i.e. may be e.g. computer free memory at a given time


property Bytes: TSynMonitorOneBytes read fBytes write fBytes;

Number of bytes, as raw number


property Text: TShort16 read GetAsText;

Number of bytes, as '... B-KB-MB-GB' text


1.3.8. TSynMonitorThroughput

TSynMonitorThroughput = class(TSynMonitorSizeParent)

Able to serialize any bandwidth as bytes count per second
- is usually associated with TSynMonitorOneSize properties, e.g. to monitor IO activity


property BytesPerSec: QWord read fBytesPerSec write fBytesPerSec;

Number of bytes per second, as raw number


property Text: TShort16 read GetAsText;

Number of bytes per second, as '... B-KB-MB-GB/s' text


1.3.9. TSynMonitor

TSynMonitor = class(TSynPersistent)

A generic value object able to handle any task / process statistic
- base class shared e.g. for ORM, SOA or DDD, when a repeatable data process is to be monitored
- this class is thread-safe for its methods, but you should call explicitly non-rentrant Lock/UnLock to access its individual properties


InternalTimer: TPrecisionTimer;

Low-level high-precision timer instance


constructor Create; overload; override;

Initialize the instance nested class properties


constructor Create(const aName: RawUtf8); reintroduce; overload; virtual;

Initialize the instance nested class properties
- you can specify identifier associated to this monitored resource which would be used for TSynMonitorUsage persistence


destructor Destroy; override;

Finalize the instance


function ComputeDetails: variant;

Returns a TDocVariant with all published properties information
- thread-safe method


function ComputeDetailsJson: RawUtf8;

Returns a JSON content with all published properties information
- thread-safe method


function RttiBeforeWriteObject(W: TTextWriter; var Options: TTextWriterWriteObjectOptions): boolean; override;

Customize JSON Serialization to set woEnumSetsAsText for readibility


procedure ComputeDetailsTo(W: TTextWriter); virtual;

Appends a JSON content with all published properties information
- thread-safe method


procedure FromExternalMicroSeconds(const MicroSecondsElapsed: QWord);

Used to allow thread safe timing
- by default, the internal TPrecisionTimer is not thread safe: you can use this method to update the timing from many threads
- if you use this method, ProcessStart, ProcessDoTask and ProcessEnd methods are disallowed, and the global fTimer won't be used any more
- this method is to be used with an external timer for thread-safety


class procedure InitializeObjArray(var ObjArr; Count: integer); virtual;

Create Count instances of this actual class in the supplied ObjArr[]


procedure Lock;

Non-reentrant exclusive lock acquisition - wrap fSafe.Lock
- warning: this non-reentrant method would deadlock if called twice


procedure ProcessDoTask;

Should be called each time a pending task is processed
- will increase the TaskCount property
- this method is not thread-safe, due to the shared InternalTimer: use an external TPrecisionTimer then FromExternalMicroSeconds()


procedure ProcessEnd; virtual;

Should be called when the process stops, to pause the internal timer
- this method is not thread-safe, due to the shared InternalTimer: use an external TPrecisionTimer then FromExternalMicroSeconds()


procedure ProcessError(const info: variant);

Should be called when an error occurred
- typical use is with ObjectToVariant(E,...) kind of information
- thread-safe method


procedure ProcessErrorFmt(const Fmt: RawUtf8; const Args: array of const);

Should be called when an error occurred
- just a wraper around overloaded ProcessError(), so a thread-safe method


procedure ProcessErrorNumber(info: integer);

Should be called when an error occurred
- typical use is with a HTTP status, e.g. as ProcessError(Call.OutStatus)
- just a wraper around overloaded ProcessError(), so a thread-safe method


procedure ProcessErrorRaised(E: Exception);

Should be called when an Exception occurred
- just a wraper around overloaded ProcessError(), so a thread-safe method


procedure ProcessStart; virtual;

Should be called when the process starts, to resume the internal timer
- this method is not thread-safe, due to the shared InternalTimer: use an external TPrecisionTimer then FromExternalMicroSeconds()


procedure ProcessStartTask; virtual;

Should be called when the process starts, and a task is processed
- similar to ProcessStart + ProcessDoTask
- this method is not thread-safe, due to the shared InternalTimer: use an external TPrecisionTimer then FromExternalMicroSeconds()


procedure Sum(another: TSynMonitor);

Could be used to manage information average or sums
- thread-safe method calling LockedSum protected virtual method


procedure UnLock;

Release the non-reentrant exclusive lock - wrap fSafe.UnLock


property AverageTime: TSynMonitorOneTime read fAverageTime;

The time spent in average during any working process


property Errors: TSynMonitorCount read fInternalErrors;

How many errors did occur during the processing


property LastError: variant read fLastInternalError;

Information about the last error which occurred during the processing


property LastTime: TSynMonitorOneTime read fLastTime;

The time spend during the last task processing


property MaximalTime: TSynMonitorOneTime read fMaximalTime;

The highest time spent during any working process


property MinimalTime: TSynMonitorOneTime read fMinimalTime;

The lowest time spent during any working process


property Name: RawUtf8 read fName write fName;

An identifier associated to this monitored resource
- is used e.g. for TSynMonitorUsage persistence/tracking


property PerSec: QWord read fPerSec;

Average of how many tasks did occur per second


property Processing: boolean read fProcessing write fProcessing;

Indicates if this thread is currently working on some process


property TaskCount: TSynMonitorCount64 read fTaskCount write fTaskCount;

How many times the task was performed


property TotalTime: TSynMonitorTime read fTotalTime;

The whole time spend during all working process


1.3.10. TSynMonitorWithSize

TSynMonitorWithSize = class(TSynMonitor)

Handle generic process statistic with a processing data size and bandwitdh


constructor Create; override;

Initialize the instance nested class properties


destructor Destroy; override;

Finalize the instance


procedure AddSize(const Bytes, MicroSecs: QWord); overload;

Increase the internal size counter and the current timer
- thread-safe method


procedure AddSize(const Bytes: QWord); overload;

Increase the internal size counter
- thread-safe method


property Size: TSynMonitorSize read fSize;

How many total data has been hanlded during all working process


property Throughput: TSynMonitorThroughput read fThroughput;

Data processing bandwidth, returned as B/KB/MB per second


1.3.11. TSynMonitorInputOutput

TSynMonitorInputOutput = class(TSynMonitor)

Handle generic process statistic with a incoming and outgoing processing data size and bandwitdh


constructor Create; override;

Initialize the instance nested class properties


destructor Destroy; override;

Finalize the instance


procedure AddSize(const Incoming, Outgoing: QWord);

Increase the internal size counters
- thread-safe method


procedure Notify(const Incoming, Outgoing, MicroSec: QWord; Status: integer);

Encapsulate AddSite + ProcessErrorNumber + FromExternalMicroSeconds


property Input: TSynMonitorSize read fInput;

How many data has been received


property InputThroughput: TSynMonitorThroughput read fInputThroughput;

Incoming data processing bandwidth, returned as B/KB/MB per second


property Output: TSynMonitorSize read fOutput;

How many data has been sent back


property OutputThroughput: TSynMonitorThroughput read fOutputThroughput;

Outgoing data processing bandwidth, returned as B/KB/MB per second


1.3.12. TSynMonitorServer

TSynMonitorServer = class(TSynMonitorInputOutput)

Could monitor a standard Server
- including Input/Output statistics and connected Clients count


function GetClientsCurrent: TSynMonitorOneCount;

Retrieve the number of connected clients
- thread-safe method


procedure AddCurrentRequestCount(diff: integer);

How many concurrent requests are currently processed
- diff is expected to be either 0, -1 or 1
- thread-safe method


procedure ClientConnect;

Update ClientsCurrent and ClientsMax
- thread-safe method


procedure ClientDisconnect;

Update ClientsCurrent and ClientsMax
- thread-safe method


procedure ClientDisconnectAll;

Update ClientsCurrent to 0
- thread-safe method


property ClientsCurrent: TSynMonitorOneCount read fClientsCurrent;

Current count of connected clients


property ClientsMax: TSynMonitorOneCount read fClientsMax;

Max count of connected clients


property CurrentRequestCount: integer read fCurrentRequestCount;

How many concurrent requests are currently processed
- modified via AddCurrentRequestCount() in TRestServer.Uri()


1.3.13. TSynMonitorUsageID

TSynMonitorUsageID = object(TObject)

How the TSynMonitorUsage storage IDs are computed
- stored e.g. in TOrmMonitorUsage.ID primary key (after a shift)
- it follows a 23 bit pattern of hour (5 bit), day (5 bit), month (4 bit), year (9 bit - starting at 2016) so that it is monotonic over time
- by default, will store the information using mugHour granularity (i.e. values for the 60 minutes in a record), and pseudo-hours of 29, 30 and 31 (see USAGE_ID_HOURMARKER[]) will identify mugDay, mugMonth and mugYear consolidated statistics
- it will therefore store up to 24*365+365+12+1 = 9138 records per year in the associated storage engine (so there is no actual need to purge it)


Value: integer;

The TID, as computed from time and granularity


function GetTime(gran: TSynMonitorUsageGranularity; monthdaystartat0: boolean = false): integer;

Low-level read of a time field stored in this ID, per granularity


function Granularity: TSynMonitorUsageGranularity;

Retrieve the resolution of the stored information
- i.e. either mugHour, mugDay, mugMonth or mugYear, which will store a true 0..23 hour value (for mugHour), or 29/30/31 pseudo-hour (i.e. USAGE_ID_HOURMARKER[mugDay/mugMonth/mugYear])


function Text(Expanded: boolean; FirstTimeChar: AnsiChar = 'T'): RawUtf8;

Convert to Iso-8601 encoded text


function ToTimeLog: TTimeLog;

Returns the date/time
- minutes and seconds will set to 0


procedure From(Y, M, D: integer); overload;

Computes an ID corresponding to mugDay granularity of a given time
- hours, minutes and seconds will be merged
- mugDay granularity will store 0..23 information about each hour
- a pseudo hour of 29 (i.e. USAGE_ID_HOURMARKER[mugDay]) is used


procedure From(Y, M, D, H: integer); overload;

Computes an ID corresponding to mugHour granularity of a given time
- minutes and seconds will be ignored
- mugHour granularity will store 0..59 information about each minute


procedure From(Y: integer); overload;

Computes an ID corresponding to mugYear granularity of a given time
- months, days, hours, minutes and seconds will be merged
- mugYear granularity will store 0..11 information about each month
- a pseudo hour of 31 (i.e. USAGE_ID_HOURMARKER[mugYear]) is used


procedure From(Y, M: integer); overload;

Computes an ID corresponding to mugMonth granularity of a given time
- days, hours, minutes and seconds will be merged
- mugMonth granularity will store 0..31 information about each day
- a pseudo hour of 30 (i.e. USAGE_ID_HOURMARKER[mugMonth]) is used


procedure FromNowUtc;

Computes an ID corresponding to the current UTC date/time
- minutes and seconds will be ignored


procedure FromTimeLog(const TimeLog: TTimeLog);

Computes an ID corresponding to a given time
- will set the ID with mugHour granularity, i.e. the information about the given hour, stored as per minute 0..59 values
- minutes and seconds in supplied TimeLog value will therefore be ignored


procedure SetTime(gran: TSynMonitorUsageGranularity; aValue: integer);

Low-level modification of a time field stored in this ID, per granularity


procedure Truncate(gran: TSynMonitorUsageGranularity);

Change the resolution of the stored information


1.3.14. TSynMonitorUsageTrackProp

TSynMonitorUsageTrackProp = record

One class property entry, as registered by TSynMonitorUsage.Track


Info: PRttiProp;

The RTTI of this integer property


Kind: TSynMonitorType;

Property type, as recognized by MonitorPropUsageValue()


Name: RawUtf8;

Internal identifier of this property


ValueLast: Int64;

The last value of this property, used to store differencies


Values: array[mugHour..mugYear] of TInt64DynArray;

The actual values of this properties, per granularty


1.3.15. TSynMonitorUsageTrack

TSynMonitorUsageTrack = record

One class instance entry, as registered by TSynMonitorUsage.Track


Instance: TObject;

The class which properties to track


Name: RawUtf8;

Internal identifier of this instance


Props: TSynMonitorUsageTrackPropDynArray;

Access to the tracked properties information


1.3.16. TSynMonitorUsage

TSynMonitorUsage = class(TSynPersistentLock)

Abstract class to track, compute and store TSynMonitor detailed statistics
- you should inherit from this class to implement proper data persistence, e.g. using TSynMonitorUsageRest for ORM-based storage
- SaveDB may take some time, so a TSynLocker OS lock is used, not TRWLock


destructor Destroy; override;

Finalize the statistics, saving any pending information


function Modified(Instance: TObject; const PropNames: array of RawUtf8; ModificationTime: TTimeLog = 0): integer; overload; virtual;

To be called when tracked properties changed on a tracked class instance


function Modified(Instance: TObject): integer; overload;

To be called when tracked properties changed on a tracked class instance


function Track(Instance: TObject; const Name: RawUtf8 = ''): integer; overload; virtual;

Track the values of one named object instance
- will recognize the TSynMonitor* properties as TSynMonitorType from RTTI, using MonitorPropUsageValue(), within any (nested) object
- the instance will be stored in fTracked[].Instance: ensure it will stay available during the whole TSynMonitorUsage process


procedure Track(const Instances: array of TSynMonitor); overload;

Track the values of the given object instances
- will recognize the TSynMonitor* properties as TSynMonitorType from RTTI, using MonitorPropUsageValue(), within any (nested) object
- instances will be stored in fTracked[].Instance: ensure they will stay available during the whole TSynMonitorUsage process


property Comment: RawUtf8 read fComment write fComment;

Some custom text, associated with the current stored state
- will be persistented by Save() methods


1.3.17. TSystemUseProcess

TSystemUseProcess = record

Internal storage of CPU and RAM usage for one process


1.3.18. TSystemUse

TSystemUse = class(TSynPersistentRWLightLock)

Monitor CPU and RAM usage of one or several processes
- you should execute BackgroundExecute on a regular pace (e.g. every second) to gather low-level CPU and RAM information for the given set of processes
- is able to keep an history of latest sample values
- use Current class function to access a process-wide instance


constructor Create(aHistoryDepth: integer = 60); reintroduce; overload; virtual;

Track the CPU and RAM usage of the current process
- you can specify the number of sample values for the History() method
- you should then execute the BackgroundExecute method of this instance in a UI timer or from a TSynBackgroundTimer.Enable() registration


constructor Create(const aProcessID: array of integer; aHistoryDepth: integer = 60); reintroduce; overload; virtual;

Track the CPU and RAM usage of the supplied set of Process ID
- any aProcessID[]=0 will be replaced by the current process ID
- you can specify the number of sample values for the History() method
- you should then execute the BackgroundExecute method of this instance in a UI timer or from a TSynBackgroundTimer.Enable() registration


class function Current(aCreateIfNone: boolean = true): TSystemUse;

Access to a global instance, corresponding to the current process
- its HistoryDepth will be of 60 items


function Data(aProcessID: integer = 0): TSystemUseData; overload;

Returns the detailed CPU and RAM usage percent of the supplied process
- aProcessID=0 will return information from the current process
- returns Timestamp=0 if the Process ID was not registered via Create/Subscribe


function Data(out aData: TSystemUseData; aProcessID: integer = 0): boolean; overload;

Returns the detailed CPU and RAM usage percent of the supplied process
- aProcessID=0 will return information from the current process
- returns -1 if the Process ID was not registered via Create/Subscribe


function History(aProcessID: integer = 0; aDepth: integer = 0): TSingleDynArray; overload;

Returns total (Kernel+User) CPU usage percent history of the supplied process
- aProcessID=0 will return information from the current process
- returns nil if the Process ID was not registered via Create/Subscribe
- returns the sample values as an array, starting from the last to the oldest
- you can customize the maximum depth, with aDepth < HistoryDepth


function HistoryData(aProcessID: integer = 0; aDepth: integer = 0): TSystemUseDataDynArray; overload;

Returns detailed CPU and RAM usage history of the supplied process
- aProcessID=0 will return information from the current process
- returns nil if the Process ID was not registered via Create/Subscribe
- returns the sample values as an array, starting from the last to the oldest
- you can customize the maximum depth, with aDepth < HistoryDepth


function HistoryText(aProcessID: integer = 0; aDepth: integer = 0; aDestMemoryMB: PRawUtf8 = nil): RawUtf8;

Returns total (Kernel+User) CPU usage percent history of the supplied process, as a string of two digits values
- aProcessID=0 will return information from the current process
- returns '' if the Process ID was not registered via Create/Subscribe
- you can customize the maximum depth, with aDepth < HistoryDepth
- the memory history (in MB) can be optionally returned in aDestMemoryMB
- on POSIX, will call RetrieveLoadAvg function for system-wide info


function HistoryVariant(aProcessID: integer = 0; aDepth: integer = 0): variant;

Returns total (Kernel+User) CPU usage percent history of the supplied process
- aProcessID=0 will return information from the current process
- returns null if the Process ID was not registered via Create/Subscribe
- returns the sample values as a TDocVariant array, starting from the last to the oldest, with two digits precision (as currency values)
- you can customize the maximum depth, with aDepth < HistoryDepth


function KB(aProcessID: integer = 0): cardinal; overload;

Returns the total (Work+Paged) RAM use of the supplied process, in KB
- aProcessID=0 will return information from the current process
- returns 0 if the Process ID was not registered via Create/Subscribe


function Percent(aProcessID: integer = 0): single; overload;

Returns the total (Kernel+User) CPU usage percent of the supplied process
- aProcessID=0 will return information from the current process
- returns -1 if the Process ID was not registered via Create/Subscribe


function PercentKernel(aProcessID: integer = 0): single; overload;

Returns the Kernel-space CPU usage percent of the supplied process
- aProcessID=0 will return information from the current process
- returns -1 if the Process ID was not registered via Create/Subscribe


function PercentSystem(out Idle, Kernel, User: single): boolean;

Percent of current Idle/Kernel/User CPU usage for all processes


function PercentUser(aProcessID: integer = 0): single; overload;

Returns the User-space CPU usage percent of the supplied process
- aProcessID=0 will return information from the current process
- returns -1 if the Process ID was not registered via Create/Subscribe


function Unsubscribe(aProcessID: integer): boolean;

Remove a Process ID from the internal tracking list


procedure OnTimerExecute(Sender: TObject);

A TTimer.OnTimer compatible event
- to be run every few seconds and retrieve the CPU and RAM use:

 tmrSystemUse.Interval := 10000; // every 10 seconds
 tmrSystemUse.OnTimer := TSystemUse.Current.OnTimerExecute;

- could also be run from a TSynBackgroundTimer instance


procedure Subscribe(aProcessID: integer);

Add a Process ID to the internal tracking list


property HistoryDepth: integer read fHistoryDepth;

How many items are stored internally, and returned by the History() method


property OnMeasured: TOnSystemUseMeasured read fOnMeasured write fOnMeasured;

Executed when TSystemUse.BackgroundExecute finished its measurement


property Timer: TObject read fTimer write fTimer;

Low-level access to the associated timer running BackgroundExecute
- equals nil if has been associated to no timer
- holds e.g. a TRestBackgroundTimer from TRest.SystemUseTrack


property UnsubscribeProcessOnAccessError: boolean read fUnsubscribeProcessOnAccessError write fUnsubscribeProcessOnAccessError;

If any unexisting (e.g. closed/killed) process should be unregistered
- e.g. if OpenProcess() API call fails


1.3.19. TSynMonitorMemory

TSynMonitorMemory = class(TSynPersistent)

Value object able to gather information about the current system memory


constructor Create(aTextNoSpace: boolean); reintroduce;

Initialize the class, and its nested TSynMonitorOneSize instances


destructor Destroy; override;

Finalize the class, and its nested TSynMonitorOneSize instances


class function FreeAsText(nospace: boolean = false; processfree: PRawUtf8 = nil): ShortString;

Some text corresponding to current 'free/total' memory information
- returns e.g. '10.3 GB / 15.6 GB'


class function PhysicalAsText(nospace: boolean = false): TShort16;

How many physical memory is currently installed, as text (e.g. '32 GB');


class function ToJson: RawUtf8;

Returns a JSON object with the current system memory information
- numbers would be given in KB (Bytes shl 10)


class function ToVariant: variant;

Fill a TDocVariant with the current system memory information
- numbers would be given in KB (Bytes shl 10)


property AllocatedReserved: TSynMonitorOneSize read GetAllocatedReserved;

Total of allocated memory reserved by the program


property AllocatedUsed: TSynMonitorOneSize read GetAllocatedUsed;

Total of allocated memory used by the program


property MemoryLoadPercent: integer read GetMemoryLoadPercent;

Percent of memory in use for the system


property PagingFileFree: TSynMonitorOneSize read GetPagingFileFree;

Free of paging file for the system


property PagingFileTotal: TSynMonitorOneSize read GetPagingFileTotal;

Total of paging file for the system


property PhysicalMemoryFree: TSynMonitorOneSize read GetPhysicalMemoryFree;

Free of physical memory for the system


property PhysicalMemoryTotal: TSynMonitorOneSize read GetPhysicalMemoryTotal;

Total of physical memory for the system


property VirtualMemoryFree: TSynMonitorOneSize read GetVirtualMemoryFree;

Free of virtual memory for the system
- property not defined under Linux, since not applying to this OS


property VirtualMemoryTotal: TSynMonitorOneSize read GetVirtualMemoryTotal;

Total of virtual memory for the system
- property not defined under Linux, since not applying to this OS


1.3.20. TSynMonitorDisk

TSynMonitorDisk = class(TSynPersistent)

Value object able to gather information about a system drive


constructor Create; override;

Initialize the class, and its nested TSynMonitorOneSize instances


destructor Destroy; override;

Finalize the class, and its nested TSynMonitorOneSize instances


class function FreeAsText: RawUtf8;

Some text corresponding to current 'free/total' disk information
- could return e.g. 'D: 64.4 GB / 213.4 GB'


property AvailableSize: TSynMonitorOneSize read GetAvailable;

Space currently available on this disk for the current user
- may be less then FreeSize, if user quotas are specified (only taken into account under Windows: on POSIX, AvailableSize=FreeSize)


property FreeSize: TSynMonitorOneSize read GetFree;

Free space currently available on this disk


property Name: TFileName read GetName;

The disk name


property TotalSize: TSynMonitorOneSize read GetTotal;

Total space


property VolumeName: SynUnicode read fVolumeName write fVolumeName;

The volume name (only available on Windows)


1.3.21. TSmbiosBios

TSmbiosBios = packed record

BIOS Information (Type 0) structure


BuildDate: RawUtf8;

2.0+ BIOS Release Date in MM/DD/YYYY format (b)
- e.g. '05/25/2022'


Characteristics: TSmbiosBiosFlags;

General features identified by this BIOS (c)


Firmware: RawUtf8;

2.4+ release version of the embedded controller firmware (f)
- e.g. '1.36'


Release: RawUtf8;

2.4+ release version of the BIOS as text (r)
- e.g. '1.70'


RomSize: RawUtf8;

2.0/2.4+ ROM Size as text (s)
- e.g. '16 MB'


VendorName: RawUtf8;

2.0+ BIOS Vendor's Name (n)
- e.g. 'LENOVO'


Version: RawUtf8;

2.0+ BIOS Version text (v)
- e.g. 'N1QET95W (1.70)'


1.3.22. TSmbiosSystem

TSmbiosSystem = packed record

System Information (Type 1) structure


Family: RawUtf8;

2.4+ Computer Family, with similar branding and cosmetic features (f)
- e.g. 'ThinkPad T470'


Manufacturer: RawUtf8;

2.0+ Manufacturer (m)
- e.g. 'LENOVO'


ProductName: RawUtf8;

2.0+ Product Name (p)
- e.g. '20HES23B0U'


Serial: RawUtf8;

2.0+ Serial Number (s)
- e.g. 'DZ4BS0A7'


Sku: RawUtf8;

2.4+ Product ID or Purchase Order Number, i.e. Sale identifier (k)
- e.g. 'LENOVO_MT_20HE_BU_Think_FM_ThinkPad'


Uuid: RawUtf8;

2.1+ Universal Unique Identifier (u)
- e.g. '02CD5F81-145E-41DB-9C53-784582A49845'


Version: RawUtf8;

2.0+ Version (v)
- e.g. 'ThinkPad T470'


WakupType: TSmbiosSystemWakeup;

2.1+ Identifies the event that caused the system to power up (w)


1.3.23. TSmbiosBoard

TSmbiosBoard = packed record

Baseboard (or Module) Information (Type 2) structure (m)


AssetTag: RawUtf8;

Asset Tag (a)
- e.g. 'Not Available'


BoardType: TSmbiosBoardType;

Type of Board (t)


Features: TSmbiosBoardFeatures;

Feature flags (f)


Location: RawUtf8;

Location within the BaseBoard Chassis (l)
- e.g. 'Not Available'


Manufacturer: RawUtf8;

Manufacturer (m)
- e.g. 'LENOVO'


Product: RawUtf8;

Product (p)
- e.g. '20HES23B0U'


Serial: RawUtf8;

Serial Number (s)
- e.g. 'B2MA42A351A'


Version: RawUtf8;

Version (v)
- e.g. 'SDK0J40697 WIN'


1.3.24. TSmbiosChassis

TSmbiosChassis = packed record

System Enclosure or Chassis (Type 3) structure


AssetTag: RawUtf8;

2.0+ Asset Tag (a)
- e.g. 'No Asset Information'


BootUpState: TSmbiosChassisState;

2.1+ State of the Chassis when it was last booted (b)


ChassisType: TSmbiosChassisType;

2.0+ Chassis Type (t)


Height: byte;

2.3+ Height of the enclosure, in "U" units, 0 means unspecified (u)


Lock: boolean;

2.0+ Chassis Lock (l)


Manufacturer: RawUtf8;

2.0+ Manufacturer (m)
- e.g. 'LENOVO'


OEM: cardinal;

2.3+ OEM-defined vendor-specific 32-bit information (o)


PowerCords: byte;

2.3+ Number of associated power cords, 0 means unspecified (c)


PowerState: TSmbiosChassisState;

2.1+ State of the Power Supply when the Chassis was last booted (w)


Security: TSmbiosChassisSecurityState;

2.1+ Physical Security Status (p)


Serial: RawUtf8;

2.0+ Serial Number (s)
- e.g. 'PS1DKS29'


ThermalState: TSmbiosChassisState;

2.1+ Thermal State of the Chassis when it was last booted (h)


Version: RawUtf8;

2.0+ Version (v)
- e.g. 'None'


1.3.25. TSmbiosCache

TSmbiosCache = packed record

Cache Information (Type 7) structure


Associativity: TSmbiosCacheAssociativity;

2.1+ Associativity (a)


CacheType: TSmbiosCacheType;

2.1+ System Cache Type (t)


Ecc: TSmbiosCacheEcc;

2.1+ Error Correction Type (e)


Enabled: boolean;

2.0+ if Cache is Enabled (b)


Level: byte;

2.0+ Cache Level 1-8 (v)


Location: TSmbiosCacheLocation;

2.0+ Location, relative to the CPU module (l)


MaxSize: RawUtf8;

2.0+/3.1+ Maximum Size in bytes (m)
- e.g. '128 KB'


OperationalMode: TSmbiosCacheMode;

2.0+ Operational Mode (o)


Size: RawUtf8;

2.0+/3.1+ Installed Size in bytes (s)
- e.g. '128 KB'


SocketDesignation: RawUtf8;

2.0+ Reference Designation of this Socket (d)
- e.g. 'L1 Cache'


Socketed: boolean;

2.0+ if Cache is Socketed (k)


Speed: byte;

2.1+ Speed in nanoseconds (n)


Sram: TSmbiosCacheSramType;

2.0+ Current SRAM type (c)


SuportedSram: TSmbiosCacheSramType;

2.0+ Supported SRAM type (r)


1.3.26. TSmbiosProcessor

TSmbiosProcessor = packed record

Processor Information (Type 4) structure


AssetTag: RawUtf8;

2.3+ Asset Tag (a)
- e.g. 'None'


BootSpeed: word;

2.0+ System Boot Speed in MHZ (k)
- e.g. 2600


CoreCount: word;

2.5+/3.0+ Number of Core per Socket (c)
- e.g. 2


CoreEnabled: word;

2.5+/3.0+ Number of Enabled Cores per Socket (e)
- e.g. 2


ExtClock: word;

2.0+ External Clock in MHz (x)
- e.g. 100


Family: word;

2.0+/2.6+ Processor family (f)
- we use an ordinal and not an enumerate because there are too much types
- see "Table 23 – Processor Information: Processor Family field" in DSP0134 SMBIOS Reference Specification 3.6.0 page 49 to 55
- the Version (v) field gives much more intelligible information


Flags: TSmbiosProcessorFlags;

2.5+ Processor Characteristics (h)


ID: RawUtf8;

2.0+ Processor 64-bit ID as hexadecimal (i)
- we don't parse the Intel CpuID flags, because only 32-bit values are truncated here so are much less than all TIntelCpuFeatures information
- e.g. 'e9060800fffbebbf'


L1Cache: TSmbiosCache;

2.1+ L1 Cache (1)


L2Cache: TSmbiosCache;

2.1+ L2 Cache (2)


L3Cache: TSmbiosCache;

2.1+ L3 Cache (3)


Manufacturer: RawUtf8;

2.0+ Manufacturer (m)
- e.g. 'Intel(R) Corporation'


MaxSpeed: word;

2.0+ Maximum Capable Speed in MHz (z)
- e.g. 2700


PartNumber: RawUtf8;

2.3+ Part Number (n)
- e.g. 'None'


Populated: boolean;

2.0+ CPU socket populated (l)


ProcessorType: TSmbiosProcessorType;

2.0+ Processor type (t)


Serial: RawUtf8;

2.3+ Serial Number (s)
- e.g. ''


SocketDesignation: RawUtf8;

2.0+ Reference Designation of this Socket (d)
- e.g. 'U3E1'


Status: TSmbiosProcessorStatus;

2.0+ CPU Status (u)
- e.g. 'Enabled'


ThreadCount: word;

2.5+/3.0+ Number of Thread Count per Socket (r)
- e.g. 4 for 2 cores / 4 threads


ThreadEnabled: word;

3.6+ Number of Enabled Threads per Socket (b)


Upgrade: TSmbiosProcessorUpgrade;

2.0+ Socket Upgrade (p)


Version: RawUtf8;

2.0+ Version (v)
- e.g. 'Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz'


Voltage: RawUtf8;

2.0+ Voltage (g)
- e.g. '1.0V'


1.3.27. TSmbiosConnector

TSmbiosConnector = packed record

Port Connector Information (Type 8) structure


ExternalName: RawUtf8;

2.0+ External Reference Designator (e)
- e.g. 'USB 1'


ExternalType: TSmbiosConnectorType;

2.0+ External Connector Type (f)


InternalName: RawUtf8;

2.0+ Internal Reference Designator (i)
- e.g. ''


InternalType: TSmbiosConnectorType;

2.0+ Internal Connector Type (j)


PortType: TSmbiosConnectorPort;

2.0+ Describes the function of the Port (p)


1.3.28. TSmbiosSlot

TSmbiosSlot = packed record

System Slot (Type 9) structure


Designation: RawUtf8;

2.0+ Slot Designation (d)
- e.g. 'Media Card Slot'


SlotType: TSmbiosSlotType;

2.0+ Slot Type (t)


Width: TSmbiosSlotWidth;

2.0+ Data Bus Width (w)


1.3.29. TSmbiosMemory

TSmbiosMemory = packed record

Memory Device (Type 17) structure


AssetTag: RawUtf8;

2.3+ Asset Tag (a)
- e.g. ''None


Bank: RawUtf8;

2.1+ Bank Locator (b)
- e.g. 'BANK 0'


DataWidth: word;

2.1+ Data width, in bits (d)


Details: TSmbiosMemoryDetails;

2.1+ Features of this Memory Type (e)


FormFactor: TSmbiosMemoryFormFactor;

2.1+ Implementation form factor (f)


Locator: RawUtf8;

2.1+ Device Locator (l)
- e.g. 'ChannelA-DIMM0'


Manufacturer: RawUtf8;

2.3+ Manufacturer (m)
- e.g. 'Samsung'


MemoryType: TSmbiosMemoryType;

2.1+ Type of Memory used by this Device (t)


MtPerSec: word;

2.3+/3.3+ Maximum Capable Speed, in Megatransfers per Seconds (c)
- e.g. 2133


PartNumber: RawUtf8;

2.3+ Part Number (p)
- e.g. 'M761A3L43CB1-CRC'


Rank: byte;

2.6+ Rank Attribute (r)


Serial: RawUtf8;

2.3+ Serial Number (n)
- e.g. '6543DB8A'


Size: RawUtf8;

2.1+/2.7+ Size of the memory device, in Bytes (s)
- e.g. '16 GB'


TotalWidth: word;

2.1+ Total width, in bits
- equal DataWidth if there is no memory correction (w)


1.3.30. TSmbiosMemoryArray

TSmbiosMemoryArray = packed record

Physical Memory Array (Type 16) structure


Device: array of TSmbiosMemory;

The Memory Device (Type 17) structure part of this Memory Array (d)


DeviceCount: word;

2.1+ Number of slots or sockets available for Memory Devices in this Memory Array (n)


Ecc: TSmbiosMemoryArrayEcc;

2.1+ Primary hardware error correction or detection method supported by this Memory Array (e)


Location: TSmbiosMemoryArrayLocation;

2.1+ Physical location of the Memory Array (l)


MaxCapacity: RawUtf8;

2.1+/2.7+ Maximum Capacity in bytes (c)
- e.g. '32 GB'


Use: TSmbiosMemoryArrayUse;

2.1+ Function for which the Memory Array is used (u)


1.3.31. TSmbiosPointingDevice

TSmbiosPointingDevice = packed record

Built-in Pointing Device (Type 21) structure


Buttons: byte;

2.1+ Number of Buttons (b)


DeviceType: TSmbiosPointingType;

2.1+ Type of Pointing Device (t)


InterfaceType: TSmbiosPointingInterface;

2.1+ Interface (i)


1.3.32. TSmbiosBattery

TSmbiosBattery = packed record

Portable Battery (Type 22) structure


Capacity: RawUtf8;

2.1+ Design Capacity in mW/h (c)
- e.g. '24.0 W/H'


Chemistry: RawUtf8;

2.2+ Identifies the battery chemistry (h)
- e.g. 'LION'


Location: RawUtf8;

2.1+ Location (l)
- e.g. 'Front'


ManufactureDate: RawUtf8;

2.2+ Manufacture Date in 'DD/MM/YYYY' format (d)
- e.g. '05/12/2017'


Manufacturer: RawUtf8;

2.1+ Manufacturer (m)
- e.g. 'SANYO'


Name: RawUtf8;

2.1+ Name (n)
- e.g. '01AV419'


Serial: RawUtf8;

2.1+ Serial Number (s)
- e.g. ''


Version: RawUtf8;

2.1+ Version (v)
- e.g. '03.01'


Voltage: RawUtf8;

2.1+ Design Capacity in mV (g)
- e.g. '11.5 V'


1.3.33. TSmbiosInfo

TSmbiosInfo = packed record

High-Level Decoded SMBIOS Information
- low-level DMI structures are decoded into ready-to-be-used text and sets
- when serialized as JSON, fields have very short identifiers (e.g. "b":{"n:"...}) which are marked in each field comment (e.g. (b) and (n))
- for serialization as binary or JSON in short or human readable form:

 b := BinarySave(@info, TypeInfo(TSmbiosInfo), rkRecordTypes);
 SaveJson(info, TypeInfo(TSmbiosInfo), [twoIgnoreDefaultInRecord], s);
 SaveJson(info, TypeInfo(TSmbiosInfo), [twoTrimLeftEnumSets, twoEnumSetsAsTextInRecord], s);

Battery: array of TSmbiosBattery;

Decoded Portable Battery (Type 22) structure (w)


Bios: TSmbiosBios;

Decoded BIOS Information (Type 0) structure (b)


Board: array of TSmbiosBoard;

Decoded Baseboard (or Module) Information (Type 2) structure (m)


Chassis: array of TSmbiosChassis;

Decoded System Enclosure or Chassis (Type 3) structure (e)


Connector: array of TSmbiosConnector;

Decoded Port Connectors Information (Type 8) structure (c)


Memory: array of TSmbiosMemoryArray;

Decoded Physical Memory Array (type 16) structure (r)
- which has nested Memory Device (Type 17) structures


Oem: TRawUtf8DynArray;

Decoded OEM Strings (Type 11) and System Configuration options (Type 12) structures (o)
- contains free-form strings defined by the OEM
- e.g. ['vboxVer_6.1.36','vboxRev_152435'] for a Virtual Box VM


PointingDevice: array of TSmbiosPointingDevice;

Decoded Built-in Pointing Device (Type 21) (d)


Processor: array of TSmbiosProcessor;

Decoded Processors Information (Type 4) structure (p)


Security: packed

Decoded Hardware Security (Type 24) structure (h)


Slot: array of TSmbiosSlot;

Decoded System Slots (Type 9) structure (t)


System: TSmbiosSystem;

Decoded System Information (Type 1) structure (s)


1.3.34. TSynFpuException

TSynFpuException = class(TSynInterfacedObject)

A simple class which will set FPU exception flags for a code block
- using an IUnknown interface to let the compiler auto-generate a try..finally block statement to reset the FPU exception register
- to be used e.g. as such:

begin
  with TSynFpuException.ForLibrayCode do
  begin
    ... now FPU exceptions will be ignored
    ... so here it is safe to call external libray code
  end; // now FPU exception will be reset as with standard Delphi

- it will avoid any unexpected invalid floating point operation in your code, whereas it was in fact triggerred in some external library code


constructor Create(ExpectedFlags: TFpuFlags); reintroduce;

Internal constructor
- do not call this constructor directly, but rather use ForLibraryCode/ForDelphiCode class methods
- for cpu32 flags are $1372 for Delphi, or $137F for library (mask all exceptions)
- for cpu64 flags are $1920 for Delphi, or $1FA0 for library (mask all exceptions)


class function ForDelphiCode: IUnknown;

After this method call, all FPU exceptions will be enabled
- this is the Delphi normal behavior
- until the method finishes (a try..finally block is generated by the compiler), then FPU execptions will be disabled again
- you have to put this e.g. before running object pascal code from a callback executed in an external libray
- this method is thread-safe and re-entrant (by reference-counting)


class function ForLibraryCode: IUnknown;

After this method call, all FPU exceptions will be ignored
- until the method finishes (a try..finally block is generated by the compiler), then FPU exceptions will be reset into "Delphi" mode
- you have to put this e.g. before calling an external libray
- this method is thread-safe and re-entrant (by reference-counting)


1.4. Types implemented in the mormot.core.perf unit

1.4.1. PPPrecisionTimer

PPPrecisionTimer = ^PPrecisionTimer;

Indirect reference to a pointer to a high resolution timer object/record


1.4.2. PPrecisionTimer

PPrecisionTimer = ^TPrecisionTimer;

Pointer to a high resolution timer object/record


1.4.3. PSynMonitor

PSynMonitor = ^TSynMonitor;

References a TSynMonitor instance


1.4.4. TOnSystemUseMeasured

TOnSystemUseMeasured = procedure(ProcessID: integer; const Data: TSystemUseData) of object;

Event handler which may be executed by TSystemUse.BackgroundExecute
- called just after the measurement of each process CPU and RAM consumption
- run from the background thread, so should not directly make UI calls, unless BackgroundExecute is run from a UI TTimer


1.4.5. TSmbiosBiosFlags

TSmbiosBiosFlags = set of ( sbfReserved0, sbfReserved1, sbfUnknonwn, sbfUnsupported, sbfIsa, sbfMca, sbfEisa, sbfPci, sbfPcmcia, sbfPlugAndPlay, sbfApm, sbfUpgradable, sbfShadowable, sbfVesa, sbfEscd, sbfBootCd, sbfBootSelectable, sbfRomSocketed, sbfBootPcmcia, sbfEdd, sbfNec12, sbfToshiba12, sbf525i360, sbf525i12, sbf35i720, sbf35i288, sbfInt5, sbfInt9, sbfInt14, sbfInt17, sbfInt10, sbfNecPc98, sbfAcpi, sbfUsbLegacy, sbfAgp, sbfBootI2O, sbfBootLS120, sbfBootZip, sbfBoot1394, sbfSmartBattery, sbfBootBiosSpecification, sbfBootKeyInitiatedNetwork, sbfTargetDistrib, sbfUefi, sbfVirtualMachine, sbfManufacturingModeSupported, sbfManufacturingModeEnabled, sbfR47, sbfR48, sbfR49, sbfR50, sbfR51, sbfR52, sbfR53, sbfR54, sbfR55, sbfR56, sbfR57, sbfR58, sbfR59 );

General features identified by this BIOS (c)
- i.e. TSmbiosBios.Characteristics field


1.4.6. TSmbiosBoardFeatures

TSmbiosBoardFeatures = set of ( sbfHostingBoard, sbfRequiresDaugtherBoard, sbfRemovable, sbfReplaceable, sbfSwappable );

Feature flags (f)
- i.e. TSmbiosBoard.Features


1.4.7. TSmbiosBoardType

TSmbiosBoardType = ( sbtUndefined, sbtUnknown, sbtOther, sbtServerBlade, sbtConnectivitySwitch, sbtSystemManagementModule, sbtProcessorModule, sbtIOModule, sbtMemoryModule, sbtDaugtherBoard, sbtMotherBoard, sbtProcessorMemoryModule, sbtProcessorIOModule, sbtInterconnectBoard );

Type of Board (t)
- i.e. TSmbiosBoard.BoardType


1.4.8. TSmbiosCacheAssociativity

TSmbiosCacheAssociativity = ( scaUndefined, scaOther, scaUnknown, scaDirectMapped, sca2way, sca4way, scaFully, sca8way, sca16way, sca12way, sca24way, sca32way, sca48way, sca64way, sca20way );

Cache Associativity (a)
- i.e. TSmbiosCache.Associativity field


1.4.9. TSmbiosCacheEcc

TSmbiosCacheEcc = ( sceUndefined, sceUnknown, sceOther, sceNone, sceParity, sceSingleBitEcc, sceMultiBitEcc );

Error Correction Type (e)
- i.e. TSmbiosCache.Ecc field


1.4.10. TSmbiosCacheLocation

TSmbiosCacheLocation = ( sclInternal, sclExternal, sclReserved, sclUnknown );

Cache Location, relative to the CPU module (l)
- i.e. TSmbiosCache.Location field


1.4.11. TSmbiosCacheMode

TSmbiosCacheMode = ( scmWriteThrough, scmWriteBack, scmVariesWithAddress, scmUnknown );

Cache Operational Mode (o)
- i.e. TSmbiosCache.OperationalMode field


1.4.12. TSmbiosCacheSramType

TSmbiosCacheSramType = set of ( sstSramOther, sstSramUnknown, sstNonBurst, sstBurst, sstPipelineBurst, sstSynchronous, sstAsynchronous );

Current/Supported SRAM type (c/r)
- i.e. TSmbiosCache.Sram/SupportedSram fields


1.4.13. TSmbiosCacheType

TSmbiosCacheType = ( sctUndefinedCache, sctOtherCache, sctNotKnown, sctInstruction, sctData, sctUnified );

System Cache Type (t)
- i.e. TSmbiosCache.CacheType field


1.4.14. TSmbiosChassisSecurityState

TSmbiosChassisSecurityState = ( scssUndefined, scssOther, scssUnknown, scssNone, scssExternalInterfaceLockedOut, scssExternalInterfaceEnabled );

Physical Security Status (p)
- i.e. TSmbiosChassis.Security field


1.4.15. TSmbiosChassisState

TSmbiosChassisState = ( scsUndefined, scsOther, scsUnknown, scsSafe, scsWarning, scsCritical, scsNonRecoverable );

State of the Chassis when it was last booted
- i.e. TSmbiosChassis.BootUpState/PowerState/ThermalState fields


1.4.16. TSmbiosChassisType

TSmbiosChassisType = ( sctUndefined, sctOther, sctUnknown, sctDesktop, sctLowProfileDesktop, sctPizzaBox, sctMiniTower, sctTower, sctPortable, sctLaptop, sctNotebook, sctHandHeld, sctDockingStation, sctAllInOne, sctSubNotebook, sctSpaceSaving, sctLunchBox, sctMainServer, sctExpansion, sctSubChassis, sctBusExpansion, sctPeripheral, sctRaid, sctRackMount, sctSealedCase, sctMultiSystem, sctCompactPci, sctAdvancedTca, sctBlade, sctBladeEnclosure, sctTablet, sctConvertible, sctDetachable, sctIoTGateway, sctEmbeddedPC, sctMiniPC, sctStickPC );

Chassis Type (t)
- i.e. TSmbiosChassis.ChassisType field


1.4.17. TSmbiosConnectorPort

TSmbiosConnectorPort = ( scpNone, scpParallelXTAT, scpParallelPS2, scpParallelECP, scpParallelEPP, scpParallelECPEPP, scpSerialXTAT, scpSerial16450, scpSerial16550, scpSerial16550A, scpScsi, scpMidi, scpJoyStick, scpKeyboard, scpMouse, scpSsaScsi, scpUsb, scpFireWire, scpPcmcia1, scpPcmcia2, scpPcmcia3, scpCardBus, scpAccessBus, scpScsi2, scpScsiWide, scpPC98, scpPC98Hireso, scpPCH98, scpVideo, scpAudio, scpModem, scpNetwork, scpSata, scpSas, scpMultiFunctionDisplayPort, scpThunderbolt );

Describes the function of the Port (p)
- i.e. TSmbiosConnector.PortType field


1.4.18. TSmbiosConnectorType

TSmbiosConnectorType = ( sctNone, sctCentronics, sctMiniCentronics, sctProprietary, sctDB25M, sctDB25F, sctDB15M, sctDB15F, sctDB9M, sctDB9F, sctRJ11, sctRJ45, sct50pinMiniScsi, sctMiniDin, sctMicroDin, sctPS2, sctInfrared, sctHPHIL, sctAccessBusUsb, sctSsaScsi, sctCircularDin8M, sctCircularDin8F, sctOnBoardIDE, sctOnBoardFloppy, sct9pinDualInline, sct25pinDualInline, sct50pinDualInline, sct68pinDualInline, sctCdromSoundInput, sctMiniCentronicsType14, sctMiniCentronicsType26, sctMinijackHeadphones, sctBnc, sct1394, sctSasSataPlug, sctUsbC, sctPC98, sctPC98Hireso, sctPCH98, sctPC98Note, sctPC98Full );

Internal/External Connector Type (j/f)
- i.e. TSmbiosConnector.InternalType/ExternalType fields


1.4.19. TSmbiosMemoryArrayEcc

TSmbiosMemoryArrayEcc = ( saeUndefined, saeOther, saeUnknown, saeNone, saeParity, saeSingleBitEcc, saeMultiBitEcc, saeCRC );

Primary hardware error correction or detection method supported
- i.e. TSmbiosMemoryArray.Ecc field


1.4.20. TSmbiosMemoryArrayLocation

TSmbiosMemoryArrayLocation = ( salUndefined, salOther, salUnknown, salMotherBoard, salIsa, salEisa, salPci, salMca, salPcmcia, salProprietary, salNuBus, salPC98C20, salPC98C24, salPC98E, salPC98LocalBus, salCXL );

Physical location of the Memory Array
- whether on the system board or an add-in board
- i.e. TSmbiosMemoryArray.Location field
- warning: salPC98C20 and later are encoded as $a0 and following bytes


1.4.21. TSmbiosMemoryArrayUse

TSmbiosMemoryArrayUse = ( sauUndefined, sauOther, sauUnknown, sauSystem, sauVideo, sauFlash, sauNonVolatileRam, sauCache );

Function for which the Memory Array is used
- i.e. TSmbiosMemoryArray.Use field


1.4.22. TSmbiosMemoryDetails

TSmbiosMemoryDetails = set of ( smdReserved, smdOther, smdUnknown, smdFastPaged, smdStaticColumn, smdPseudoStatic, smdRambus, smdSynchronous, smdCmos, smdEdo, smdWindowDram, smdCacheDram, smdNonVolatile, smdRegisteredBuffered, smdUnbufferedUnRegistered, smdLrdimm );

Features of this Memory Type (e)
- i.e. TSmbiosMemory.Details field


1.4.23. TSmbiosMemoryFormFactor

TSmbiosMemoryFormFactor = ( smfUndefined, smfOther, smfUnknown, smfSimm, smfSip, smfChip, smfDip, smfZip, smfProprietaryCard, smfDimm, smfTsop, smfRowOfCips, smfRimm, smfSodimm, smfSrimm, smfFbDimm, smfDie );

Memory Implementation form factor (f)
- i.e. TSmbiosMemory.FormFactor field


1.4.24. TSmbiosMemoryType

TSmbiosMemoryType = ( smtUndefined, smtOther, smtUnknown, smtDRAM, smtEDRAM, smtVRAM, smtSRAM, smtRAM, smtROM, smtFLASH, smtEEPROM, smtFEPROM, smtEPROM, smtCDRAM, smt3DRAM, smtSDRAM, smtSGRAM, smtRDRAM, smtDDR, smtDDR2, smtDDR2FBDIMM, smt15, smt16, smt17, smtDDR3, smtFBD2, smtDDR4, smtLPDDR, smtLPDDR2, smtLPDDR3, smtLPDDR4, smtLogicalNonVolatileDevice, smtHBM, smtHBM2, smtDDR5, smtLPDDR5, smtHBM3 );

Type of Memory used by this Device (t)
- i.e. TSmbiosMemory.MemoryType field


1.4.25. TSmbiosPointingInterface

TSmbiosPointingInterface = ( spiUndefined, spiOther, spiUnknown, spiSerial, spiPS2, spiInfrared, spiHpHil, spiBusMouse, spiADB, spiBusMouseDB9, spiBusMouseMicroDin, spiUSB, spiI2C, spiSPI );

Interface of Pointing Device (i)
- i.e. TSmbiosPointingDevice.InterfaceType field


1.4.26. TSmbiosPointingType

TSmbiosPointingType = ( sptUndefinedDevice, sptOtherDevice, sptUnknownDevice, sptMouse, sptTrackBall, sptTrackPoint, sptGlidePoint, sptTouchPad, sptTouchScreen, sptOpticalSensor );

Type of Pointing Device (t)
- i.e. TSmbiosPointingDevice.DeviceType field


1.4.27. TSmbiosProcessorFlags

TSmbiosProcessorFlags = set of ( spfReserved, spfUnknown, spf64Bit, spfMultiCore, spfHardwareThread, spfNXSupport, spfVirtSupport, spfPowerControl, spf128Bit, spfArm64SocID );

Processor Characteristics (h)
- i.e. TSmbiosProcessor.Flags field


1.4.28. TSmbiosProcessorStatus

TSmbiosProcessorStatus = ( spsUnknown, spsEnabled, spsDisabledByUserInBios, spsDisabledByBiosOnError, spsIdle );

CPU Status (u)
- i.e. TSmbiosProcessor.Status field


1.4.29. TSmbiosProcessorType

TSmbiosProcessorType = ( sptUndefined, sptOther, sptUnknown, sptCentral, sptMath, sptDsp, sptVideo );

Processor type (t)
- i.e. TSmbiosProcessor.ProcessorType field


1.4.30. TSmbiosProcessorUpgrade

TSmbiosProcessorUpgrade = ( spuReserved, spuOther, spuUnknown, spuDaughterBoard, spuZIF, spuReplaceablePiggyBack, spuNone, spuLIF, spuSlot1, spuSlot2, spu370pin, spuSlotA, spuSlotM, spu423, spuA462, spu478, spu754, spu940, spu939, spumPGA604, spuLGA771, spuLGA775, spuS1, spuAM2, spuF1207, spuLGA1366, spuG34, spuAM3, spuC32, spuLGA1156, spuLGA1567, spuPGA988A, spuBGA1288, spurPGA988B, spuBGA1023, spuBGA1224, spuBGA1155, spuLGA1356, spuLGA2011, spuFS1, spuFS2, spuFM1, spuFM2, spuLGA2011_3, spuLGA1356_3, spuLGA1150, spuBGA1168, spuBGA1234, spuBGA1364, spuAM4, spuLGA1151, spuBGA1356, spuBGA1440, spuBGA1515, spuLGA3647_1, spuSP3, spuSP3r2, spuLGA2066, spuBGA1392, spuBGA1510, spuBGA1528, spuLGA4189, spuLGA1200, spuLGA4677, spuLGA1700, spuBGA1744, spuBGA1781, spuBGA1211, spuBGA2422, spuLGA1211, spuLGA2422, spuLGA5773, spuBGA5773 );

Socket Upgrade (p)
- i.e. TSmbiosProcessor.Upgrade field


1.4.31. TSmbiosSecurityStatus

TSmbiosSecurityStatus = ( sssDisabled, sssEnabled, sssNotImplemented, sssUnknown );

Decoded Hardware Security (Type 24) status
- i.e. TSmbiosInfo.Security fields


1.4.32. TSmbiosSlotType

TSmbiosSlotType = ( sstUndefined, sstOther, sstUnknown, sstIsa, sstMca, sstEisa, sstPci, sstPcmcia, sstVlVesa, sstProprietary, sstProcessorCard, sstProprietaryMemoryCard, sstIORiserCard, sstNuBus, sstPci66Mhz, sstAgp, sstAgp2X, sstAgp4X, sstPciX, sstAgp8X, sstM2Socket1DP_A, sstM2Socket1SD_E, sstM2Socket2_B, sstM2Socket3_M, sstMxm1, sstMxm2, sstMxm3, sstMxm3He, sstMxm4, sstMxm3A, sstMxm3B, sstPcieGen2, sstPcieGen3, sstPcieMini52pin_A, sstPcieMini52pin_B, sstPcieMini76pin, sstPcieGen4, sstPcieGen5, sstOcpNic3SFF, sstOcpNic3LFF, sstOcpNic, sstPC98C20, sstPC98C24, sstPC98E, sstPC98LocalBus, sstPC98Card, sstPcie, sstPcieX1, sstPcieX2, sstPcieX4, sstPcieX8, sstPcieX16, sstPcieGen2x, sstPcieGen2x1, sstPcieGen2x2, sstPcieGen2x4, sstPcieGen2x8, sstPcieGen2x16, sstPcieGen3x, sstPcieGen3x1, sstPcieGen3x2, sstPcieGen3x4, sstPcieGen3x8, sstPcieGen3x16, sstPcieGen4x, sstPcieGen4x1, sstPcieGen4x2, sstPcieGen4x4, sstPcieGen4x8, sstPcieGen4x16, sstPcieGen5x, sstPcieGen5x1, sstPcieGen5x2, sstPcieGen5x4, sstPcieGen5x8, sstPcieGen5x16, sstPcieGen6, sst1UE1FormFactor, sst3UE3FormFactor );

Slot Type (t)
- i.e. TSmbiosSlot.SlotType field
- warning: sstPC98C20 and following are encoded as A0H and next bytes


1.4.33. TSmbiosSlotWidth

TSmbiosSlotWidth = ( sswUndefinedSlotWidth, sswOtherSlotWidth, sswUnknownSlotWidth, ssw8bit, ssw16bit, ssw32bit, ssw64bit, ssw128bit, sswX1, sswX2, sswX4, sswX8, sswX12, sswX16, sswX32 );

Data Bus Width (w)
- i.e. TSmbiosSlot.Width field


1.4.34. TSmbiosSystemWakeup

TSmbiosSystemWakeup = ( sswReserved, sswOther, sswUnknown, sswApmTimer, sswModemRing, sswLanRemote, sswPowerSwitch, sswPciPme, sswAcPowerRestored );

Identifies the event that caused the system to power up (w)
- i.e. TSmbiosSystem.WakeupType field


1.4.35. TSynMonitorBytesPerSec

TSynMonitorBytesPerSec = type QWord;

Would identify the process throughput, during monitoring
- it indicates e.g. "immediate" bandwidth usage
- any property defined with this type would be identified by TSynMonitorUsage


1.4.36. TSynMonitorClass

TSynMonitorClass = class of TSynMonitor;

Class-reference type (metaclass) of a process statistic information


1.4.37. TSynMonitorCount

TSynMonitorCount = type cardinal;

Would identify a cumulative number of processes, during monitoring
- any property defined with this type would be identified by TSynMonitorUsage


1.4.38. TSynMonitorCount64

TSynMonitorCount64 = type QWord;

Would identify a cumulative number of processes, during monitoring
- any property defined with this type would be identified by TSynMonitorUsage


1.4.39. TSynMonitorInputOutputObjArray

TSynMonitorInputOutputObjArray = array of TSynMonitorInputOutput;

A list of incoming/outgoing data process statistics


1.4.40. TSynMonitorObjArray

TSynMonitorObjArray = array of TSynMonitor;

A list of simple process statistics


1.4.41. TSynMonitorOneBytes

TSynMonitorOneBytes = type QWord;

Would identify an immediate process information as bytes count, during monitoring
- "immediate" size won't accumulate, i.e. may be e.g. computer free memory at a given time
- any property defined with this type would be identified by TSynMonitorUsage


1.4.42. TSynMonitorOneCount

TSynMonitorOneCount = type cardinal;

Would identify an immediate time count information, during monitoring
- "immediate" counts won't accumulate, e.g. may store the current number of thread used by a process
- any property defined with this type would be identified by TSynMonitorUsage


1.4.43. TSynMonitorOneMicroSec

TSynMonitorOneMicroSec = type QWord;

Would identify an immediate time process information in micro seconds, during monitoring
- "immediate" time won't accumulate, i.e. may store the duration of the latest execution of a SOA computation
- any property defined with this type would be identified by TSynMonitorUsage


1.4.44. TSynMonitorTotalBytes

TSynMonitorTotalBytes = type QWord;

Would identify a process information as cumulative bytes count, during monitoring
- "cumulative" size would add some byte for each process, e.g. input/output
- any property defined with this type would be identified by TSynMonitorUsage


1.4.45. TSynMonitorTotalMicroSec

TSynMonitorTotalMicroSec = type QWord;

Would identify a cumulative time process information in micro seconds, during monitoring
- "cumulative" time would add each process timing, e.g. for statistics about SOA computation of a given service
- any property defined with this type would be identified by TSynMonitorUsage


1.4.46. TSynMonitorType

TSynMonitorType = ( smvUndefined, smvOneMicroSec, smvOneBytes, smvOneCount, smvBytesPerSec, smvMicroSec, smvBytes, smvCount, smvCount64 );

The kind of value stored in a TSynMonitor / TSynMonitorUsage property
- i.e. match TSynMonitorTotalMicroSec, TSynMonitorOneMicroSec, TSynMonitorOneCount, TSynMonitorOneBytes, TSynMonitorBytesPerSec, TSynMonitorTotalBytes, TSynMonitorCount and TSynMonitorCount64 types as used to store statistic information
- "cumulative" values would sum each process values, e.g. total elapsed time for SOA execution, task count or total I/O bytes
- "immediate" (e.g. svOneBytes or smvBytesPerSec) values would be an evolving single value, e.g. an average value or current disk free size
- use SYNMONITORVALUE_CUMULATIVE = [smvMicroSec,smvBytes,smvCount,smvCount64] constant to identify the kind of value
- TSynMonitorUsage.Track() would use MonitorPropUsageValue() to guess the tracked properties type from class RTTI


1.4.47. TSynMonitorTypes

TSynMonitorTypes = set of TSynMonitorType;

Value types as stored in TSynMonitor / TSynMonitorUsage


1.4.48. TSynMonitorUsageGranularities

TSynMonitorUsageGranularities = set of TSynMonitorUsageGranularity;

Defines one or several time periods for TSynMonitorUsage process


1.4.49. TSynMonitorUsageGranularity

TSynMonitorUsageGranularity = ( mugUndefined, mugMinute, mugHour, mugDay, mugMonth, mugYear );

The time periods covered by TSynMonitorUsage process
- defines the resolution of information computed and stored


1.4.50. TSynMonitorUsageLoad

TSynMonitorUsageLoad = array[mugHour..mugYear] of variant;

Define all known information about a given time, as persisted
- store a TDocVariant object with per-name fields of Values[Gran] arrays
- may be the current time, or a former time


1.4.51. TSynMonitorUsageTrackPropDynArray

TSynMonitorUsageTrackPropDynArray = array of TSynMonitorUsageTrackProp;

The class properties, as registered by TSynMonitorUsage.Track


1.4.52. TSynMonitorWithSizeObjArray

TSynMonitorWithSizeObjArray = array of TSynMonitorWithSize;

A list of data process statistics


1.4.53. TSystemUseProcessDynArray

TSystemUseProcessDynArray = array of TSystemUseProcess;

Internal storage of CPU and RAM usage for a set of processes


1.5. Constants implemented in the mormot.core.perf unit

1.5.1. SYNMONITORVALUE_CUMULATIVE

SYNMONITORVALUE_CUMULATIVE = [smvMicroSec, smvBytes, smvCount, smvCount64];

Kind of "cumulative" TSynMonitorType stored in TSynMonitor / TSynMonitorUsage
- those properties will have their values reset for each granularity level
- will recognize TSynMonitorTotalMicroSec, TSynMonitorTotalBytes, TSynMonitorOneBytes, TSynMonitorBytesPerSec, TSynMonitorCount and TSynMonitorCount64 types


1.6. Functions or procedures implemented in the mormot.core.perf unit

Functions or proceduresDescription
DecodeSmbiosInfoDecode SMBIOS raw binary into high-level usable information
GetDiskPartitionsTextRetrieve low-level information about all mounted disk partitions as text
GetLastExceptionsReturns a TDocVariant array of the latest intercepted exception texts
GetSmbiosInfoRetrieve and decode DMI/SMBIOS data into high-level Smbios global variable
MergeSmbiosInfoAppend TSmbiosBasicInfos fields to TSmbiosInfo
MonitorPropUsageValueGuess the kind of value stored in a TSynMonitor / TSynMonitorUsage property
SystemInfoJsonReturns a JSON object containing basic information about the computer
ToTextConvert ARM 64-bit CPU features as plain CSV text
ToTextConvert Intel CPU features as plain CSV text
ToTextConvert ARM 32-bit CPU features as plain CSV text

1.6.1. DecodeSmbiosInfo

function DecodeSmbiosInfo(const raw: TRawSmbiosInfo; out info: TSmbiosInfo; intern: TRawUtf8Interning = nil): boolean;

Decode SMBIOS raw binary into high-level usable information
- see also mormot.core.os.pas DecodeSmbios() more limited function
- optionally intern the strings, e.g. if you maintain several SMBIOS instances


1.6.2. GetDiskPartitionsText

function GetDiskPartitionsText(nocache: boolean = false; withfreespace: boolean = false; nospace: boolean = false; nomount: boolean = false): RawUtf8;

Retrieve low-level information about all mounted disk partitions as text
- returns e.g. under Linux '/ /dev/sda3 (19 GB), /boot /dev/sda2 (486.8 MB), /home /dev/sda4 (0.9 TB)' or under Windows 'C:\ System (115 GB), D:\ Data (99.3 GB)'
- uses internally a cache unless nocache is true
- includes the free space if withfreespace is true - e.g. '(80 GB / 115 GB)'


1.6.3. GetLastExceptions

function GetLastExceptions(Depth: integer = 0): variant; overload;

Returns a TDocVariant array of the latest intercepted exception texts
- runs ToText() over all information returned by overloaded GetLastExceptions
- defined in this unit to have TDocVariant at hand


1.6.4. GetSmbiosInfo

function GetSmbiosInfo: boolean;

Retrieve and decode DMI/SMBIOS data into high-level Smbios global variable
- on POSIX, requires at least once root to access SMBIOS raw memory so may return false unless the information has been cached locally
- if there is no SMBIOS information (e.g. not enough current user rights), will call MergeSmbiosInfo() to try and fill Smbios from _Smbios items
- see also mormot.core.os.pas GetSmbios() more limited function


1.6.5. MergeSmbiosInfo

procedure MergeSmbiosInfo(const basic: TSmbiosBasicInfos; var info: TSmbiosInfo);

Append TSmbiosBasicInfos fields to TSmbiosInfo
- use basic[] values if info fields are void


1.6.6. MonitorPropUsageValue

function MonitorPropUsageValue(info: PRttiProp): TSynMonitorType;

Guess the kind of value stored in a TSynMonitor / TSynMonitorUsage property
- will recognize TSynMonitorTotalMicroSec, TSynMonitorOneMicroSec, TSynMonitorTotalBytes, TSynMonitorOneBytes, TSynMonitorBytesPerSec, TSynMonitorCount and TSynMonitorCount64 types from supplied RTTI


1.6.7. SystemInfoJson

function SystemInfoJson: RawUtf8;

Returns a JSON object containing basic information about the computer
- including Host, User, CPU, OS, freemem, freedisk...


1.6.8. ToText

function ToText(const aArm32CPUFeatures: TArm32HwCaps; const Sep: RawUtf8 = ','): RawUtf8; overload;

Convert ARM 32-bit CPU features as plain CSV text


1.6.9. ToText

function ToText(const aIntelCPUFeatures: TIntelCpuFeatures; const Sep: RawUtf8 = ','): RawUtf8; overload;

Convert Intel CPU features as plain CSV text


1.6.10. ToText

function ToText(const aArm64CPUFeatures: TArm64HwCaps; const Sep: RawUtf8 = ','): RawUtf8; overload;

Convert ARM 64-bit CPU features as plain CSV text


1.7. Variables implemented in the mormot.core.perf unit

1.7.1. CpuFeaturesText

CpuFeaturesText: RawUtf8;

Contains the current CPU Features as space-separated text
- computed from CpuFeatures set for Intel/AMD or ARM 32-bit/64-bit
- contains the Flags: or Features: value of Linux /proc/cpuinfo otherwise (less accurate than our CpuFeatures set on older kernel)


1.7.2. Smbios

Smbios: TSmbiosInfo;

Global variable filled by GetSmbiosInfo from SMBIOS binary information