NcmTimer

NcmTimer — A timer with ETA support.

Stability Level

Stable, unless otherwise indicated

Functions

Properties

char * name Read / Write / Construct
guint task-len Read
guint task-pos Read

Types and Values

Object Hierarchy

    GObject
    ╰── NcmTimer

Includes

#include <numcosmo/math/ncm_timer.h>

Description

This object has several functions to track time, with the availability to be devided in several tasks. Also it provides two different formats: the default is time in seconds but also have date plus time. All with estimated time of accomplishment (ETA) support.

Functions

ncm_timer_new ()

NcmTimer *
ncm_timer_new (void);

This function creates a new NcmTimer.

Returns

a new NcmTimer.

[transfer full]


ncm_timer_ref ()

NcmTimer *
ncm_timer_ref (NcmTimer *nt);

Increases the reference count of nt by one.

Parameters

nt

a NcmTimer

 

Returns

nt .

[transfer full]


ncm_timer_free ()

void
ncm_timer_free (NcmTimer *nt);

Decreases the reference count of nt by one.

Parameters

nt

a NcmTimer

 

ncm_timer_clear ()

void
ncm_timer_clear (NcmTimer **nt);

Decreases the reference count of *nt by one and sets *nt to NULL.

Parameters

nt

a NcmTimer

 

ncm_timer_set_name ()

void
ncm_timer_set_name (NcmTimer *nt,
                    const gchar *name);

This functions set the named name to the nt NcmTimer.

Parameters

nt

a NcmTimer

 

name

a string

 

ncm_timer_elapsed ()

gdouble
ncm_timer_elapsed (NcmTimer *nt);

If nt timer has been started but not stopped, obtains the time since the timer was started. If timer has been stopped, obtains the elapsed time between the time it was started and the time it was stopped. The return value is the number of seconds elapsed, including any fractional part. This function applies g_timer_elapsed() from Glib.

Parameters

nt

a NcmTimer

 

Returns

seconds elapsed as a floating point value, including any fractional part.


ncm_timer_elapsed_dhms ()

void
ncm_timer_elapsed_dhms (NcmTimer *nt,
                        guint *elap_day,
                        guint *elap_hour,
                        guint *elap_min,
                        gdouble *elap_sec);

The this function returns the same information as above, but now the format is in days, hours, minutes and seconds. Those information are passed by the variables elap_day , elap_hour , elap_min and elap_sec , respectively.

Parameters

nt

a NcmTimer

 

elap_day

elapsed days.

[out]

elap_hour

elapsed hours.

[out]

elap_min

elapsed minutes.

[out]

elap_sec

elapsed seconds.

[out]

ncm_timer_elapsed_dhms_str ()

gchar *
ncm_timer_elapsed_dhms_str (NcmTimer *nt);

Similar as the function above, but now the resulted time elapsed is returned in a string format.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_start ()

void
ncm_timer_start (NcmTimer *nt);

This function starts nt timer. nt must not have a task running.

Parameters

nt

a NcmTimer

 

ncm_timer_stop ()

void
ncm_timer_stop (NcmTimer *nt);

This function stop nt timer. nt must not have a task running.

Parameters

nt

a NcmTimer

 

ncm_timer_continue ()

void
ncm_timer_continue (NcmTimer *nt);

This function continues nt timer. nt must not have a task running.

Parameters

nt

a NcmTimer

 

ncm_timer_task_start ()

void
ncm_timer_task_start (NcmTimer *nt,
                      guint task_len);

This function starts a task at nt with lenght task_len . nt must not have a task already assigned to it. task_len must be bigger than 0, task_len >0.

Parameters

nt

a NcmTimer

 

task_len

number of task

 

ncm_timer_task_pause ()

void
ncm_timer_task_pause (NcmTimer *nt);

This function pauses a nt task. The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

ncm_timer_task_continue ()

void
ncm_timer_task_continue (NcmTimer *nt);

This function resumes a nt task. The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

ncm_timer_task_add_tasks ()

void
ncm_timer_task_add_tasks (NcmTimer *nt,
                          guint ptasks);

This function adds ptasks to nt . The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

ptasks

number of taks to be added

 

ncm_timer_task_increment ()

void
ncm_timer_task_increment (NcmTimer *nt);

This function increment nt task by one. The final task ID must be greater than the task length defined by ncm_timer_task_start().

Parameters

nt

a NcmTimer

 

ncm_timer_task_accumulate ()

void
ncm_timer_task_accumulate (NcmTimer *nt,
                           guint nitens);

This function takes a task already created and divids it in nitens . The number of nitens must not exceed the length of the original task.

Parameters

nt

a NcmTimer

 

nitens

number of itens to include in the task

 

ncm_timer_task_completed ()

guint
ncm_timer_task_completed (NcmTimer *nt);

This function returns the number of tasks already completed. The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

Returns

the number of tasks already completed.


ncm_timer_task_estimate_by_time ()

guint
ncm_timer_task_estimate_by_time (NcmTimer *nt,
                                 gdouble sec);

This function estimate how many task points would take sec seconds.

Parameters

nt

a NcmTimer

 

sec

time in seconds

 

Returns

the estimated number of points.


ncm_timer_task_is_running ()

gboolean
ncm_timer_task_is_running (NcmTimer *nt);

This functions verify if nt has a task already running.

Parameters

nt

a NcmTimer

 

ncm_timer_task_has_ended ()

gboolean
ncm_timer_task_has_ended (NcmTimer *nt);

This function verifies if nt task has ended. The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

Returns

TRUE if the task has ended, FALSE otherwise.


ncm_timer_task_end ()

gboolean
ncm_timer_task_end (NcmTimer *nt);

This function ends nt task. The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

Returns

TRUE if the task is finished, FALSE otherwise.


ncm_timer_elapsed_since_last_log ()

gdouble
ncm_timer_elapsed_since_last_log (NcmTimer *nt);

This function returns the elapsed time since the last log.

Parameters

nt

a NcmTimer

 

Returns

elapsed time since the last log.


ncm_timer_task_mean_time ()

gdouble
ncm_timer_task_mean_time (NcmTimer *nt);

This function returns the mean time between all nt task.

Parameters

nt

a NcmTimer

 

Returns

nt tasks mean time.


ncm_timer_task_time_left ()

gdouble
ncm_timer_task_time_left (NcmTimer *nt);

This function calculates the time for the remaining tasks of nt .

Parameters

nt

a NcmTimer

 

Returns

tasks time left.


ncm_timer_task_elapsed_str ()

const gchar *
ncm_timer_task_elapsed_str (NcmTimer *nt);

This function returns a string wiht the time needed to complete the tasks until the program reaches it. The nt task length must be greater than 0.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_task_mean_time_str ()

const gchar *
ncm_timer_task_mean_time_str (NcmTimer *nt);

This function returns astring with the average time to go through each task.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_task_time_left_str ()

const gchar *
ncm_timer_task_time_left_str (NcmTimer *nt);

This function returns a string with the time left to execute the remaining tasks.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_task_start_datetime_str ()

const gchar *
ncm_timer_task_start_datetime_str (NcmTimer *nt);

This function returns a string wiht the start time of the nt task in date plus time format.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_task_cur_datetime_str ()

const gchar *
ncm_timer_task_cur_datetime_str (NcmTimer *nt);

This function returns a string with the current time of the nt task in date plus time format.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_task_end_datetime_str ()

const gchar *
ncm_timer_task_end_datetime_str (NcmTimer *nt);

This function returns a string with the end time of the nt task in date plus time format.

Parameters

nt

a NcmTimer

 

Returns

a string.

[transfer none]


ncm_timer_task_log_elapsed ()

void
ncm_timer_task_log_elapsed (NcmTimer *nt);

This function log the time elapsed through all nt 's tasks.

Parameters

nt

a NcmTimer

 

ncm_timer_task_log_mean_time ()

void
ncm_timer_task_log_mean_time (NcmTimer *nt);

This function log the mean time elapsed of each of the nt tasks.

Parameters

nt

a NcmTimer

 

ncm_timer_task_log_time_left ()

void
ncm_timer_task_log_time_left (NcmTimer *nt);

This function log the time left of the nt 's remaining tasks.

Parameters

nt

a NcmTimer

 

ncm_timer_task_log_start_datetime ()

void
ncm_timer_task_log_start_datetime (NcmTimer *nt);

This function log the start time of the nt 's tasks in date plus time format.

Parameters

nt

a NcmTimer

 

ncm_timer_task_log_cur_datetime ()

void
ncm_timer_task_log_cur_datetime (NcmTimer *nt);

This function log the current time of the nt 's tasks in date plus time format.

Parameters

nt

a NcmTimer

 

ncm_timer_task_log_end_datetime ()

void
ncm_timer_task_log_end_datetime (NcmTimer *nt);

This function log the end time of the nt 's tasks in date plus time format.

Parameters

nt

a NcmTimer

 

Types and Values

NCM_TYPE_TIMER

#define NCM_TYPE_TIMER (ncm_timer_get_type ())

NCM_TIMER_SEC_FORMAT

#define NCM_TIMER_SEC_FORMAT "%07.4f"

NcmTimer

typedef struct _NcmTimer NcmTimer;

Property Details

The “name” property

  “name”                     char *

The timer's name.

Owner: NcmTimer

Flags: Read / Write / Construct

Default value: "timer"


The “task-len” property

  “task-len”                 guint

The length of the current task.

Owner: NcmTimer

Flags: Read

Default value: 0


The “task-pos” property

  “task-pos”                 guint

The Position of the current task, varying from [0, “task-len” - 1]

Owner: NcmTimer

Flags: Read

Default value: 0