Differenze tra le versioni di "Conoscere con le funzioni esterne della libreria standard C "time.h" la risoluzione dei clock hardware"

Da Gambas-it.org - Wikipedia.
(Creata pagina con "Con alcune funzioni esterne della libreria standard C "''time.h''" è possibile conoscere la risoluzione di alcuni tipi di ''clock'' hardware. E' necessario avere installata...")
 
Riga 1: Riga 1:
 
Con alcune funzioni esterne della libreria standard C "''time.h''" è possibile conoscere la risoluzione di alcuni tipi di ''clock'' hardware.
 
Con alcune funzioni esterne della libreria standard C "''time.h''" è possibile conoscere la risoluzione di alcuni tipi di ''clock'' hardware.
  
E' necessario avere installata nel proprio sistema e deve esere richiamata in gambas la libreria dinamica condivisa: "''libboost_date_time.so.1.54.0''"
+
E' necessario avere installata nel proprio sistema e deve esere richiamata in gambas la libreria condivisa: "''libboost_date_time.so.1.71.0'' ".
 
 
  
 
Mostriamo un semplice esempio:
 
Mostriamo un semplice esempio:
  Library "libboost_date_time:1.54.0"
+
  Library "libboost_date_time:1.71.0"
 
   
 
   
 
  Private Enum CLOCK_REALTIME = 0, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID, CLOCK_MONOTONIC_RAW,
 
  Private Enum CLOCK_REALTIME = 0, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID, CLOCK_MONOTONIC_RAW,
Riga 23: Riga 22:
 
    
 
    
 
   Dim spec As New Timespec
 
   Dim spec As New Timespec
 +
 +
  clock_getres(CLOCK_REALTIME, spec)
 +
  Print "CLOCK_REALTIME:            sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 
    
 
    
  clock_getres(CLOCK_REALTIME, spec)
+
  clock_getres(CLOCK_MONOTONIC, spec)
  Print "CLOCK_REALTIME:           sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
+
  Print "CLOCK_MONOTONIC:           sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 
    
 
    
  clock_getres(CLOCK_MONOTONIC, spec)
+
   clock_getres(CLOCK_MONOTONIC_RAW, spec)
  Print "CLOCK_MONOTONIC:          sec. "; spec.tv_sec; "   ns "; spec.tv_nsec
+
  Print "CLOCK_MONOTONIC_RAW:      sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
   
 
  clock_getres(CLOCK_MONOTONIC_RAW, spec)
 
  Print "CLOCK_MONOTONIC_RAW:      sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 
   
 
  clock_getres(CLOCK_PROCESS_CPUTIME_ID, spec)
 
  Print "CLOCK_PROCESS_CPUTIME_ID:  sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 
   
 
  clock_getres(CLOCK_THREAD_CPUTIME_ID, spec)
 
  Print "CLOCK_THREAD_CPUTIME_ID:  sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 
 
    
 
    
 +
  clock_getres(CLOCK_PROCESS_CPUTIME_ID, spec)
 +
  Print "CLOCK_PROCESS_CPUTIME_ID:  sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 +
 
 +
  clock_getres(CLOCK_THREAD_CPUTIME_ID, spec)
 +
  Print "CLOCK_THREAD_CPUTIME_ID:  sec. "; spec.tv_sec; "  ns "; spec.tv_nsec
 +
 
 
  '''End'''
 
  '''End'''
 
  
  

Versione delle 14:45, 4 set 2022

Con alcune funzioni esterne della libreria standard C "time.h" è possibile conoscere la risoluzione di alcuni tipi di clock hardware.

E' necessario avere installata nel proprio sistema e deve esere richiamata in gambas la libreria condivisa: "libboost_date_time.so.1.71.0 ".

Mostriamo un semplice esempio:

Library "libboost_date_time:1.71.0"

Private Enum CLOCK_REALTIME = 0, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID, CLOCK_MONOTONIC_RAW,
             CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME, CLOCK_REALTIME_ALARM, CLOCK_BOOTTIME_ALARM

Public Struct timespec
  tv_sec As Long          ' Secondi
  tv_nsec As Long         ' Nanosecondi
End Struct
 
' int clock_getres (clockid_t __clock_id, struct timespec *__res)
' Get resolution of clock CLOCK_ID.
Private Extern clock_getres(__clock_id As Integer, __res As Timespec) As Integer


Public Sub Main()
 
 Dim spec As New Timespec

 clock_getres(CLOCK_REALTIME, spec)
 Print "CLOCK_REALTIME:            sec. "; spec.tv_sec; "   ns "; spec.tv_nsec
 
 clock_getres(CLOCK_MONOTONIC, spec)
 Print "CLOCK_MONOTONIC:           sec. "; spec.tv_sec; "   ns "; spec.tv_nsec
  
 clock_getres(CLOCK_MONOTONIC_RAW, spec)
 Print "CLOCK_MONOTONIC_RAW:       sec. "; spec.tv_sec; "   ns "; spec.tv_nsec
  
 clock_getres(CLOCK_PROCESS_CPUTIME_ID, spec)
 Print "CLOCK_PROCESS_CPUTIME_ID:  sec. "; spec.tv_sec; "   ns "; spec.tv_nsec
  
 clock_getres(CLOCK_THREAD_CPUTIME_ID, spec)
 Print "CLOCK_THREAD_CPUTIME_ID:   sec. "; spec.tv_sec; "   ns "; spec.tv_nsec
 
End


Riferimenti