<commit_before>/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014.  ALL RIGHTS RESERVED.
*
* $COPYRIGHT$
* $HEADER$
*/

#ifndef UCS_TIME_H
#define UCS_TIME_H

#include <ucs/sys/sys.h>
#include <ucs/sys/math.h>


/**
 * UCS time units.
 * These are not necessarily aligned with metric time units.
 * MUST compare short time values with UCS_SHORT_TIME_CMP to handle wrap-around.
 */
typedef unsigned long long   ucs_time_t;

/**
 * Short time type
 * Used to represent short time intervals, and takes less memory.
 */
typedef uint32_t             ucs_short_time_t;

/**
 * Compare short time values
 */
#define UCS_SHORT_TIME_CMP  UCS_CIRCULAR_COMPARE32


#define UCS_TIME_INFINITY  ULLONG_MAX

#define UCS_MSEC_PER_SEC   1000ull       /* Milli */
#define UCS_USEC_PER_SEC   1000000ul     /* Micro */
#define UCS_NSEC_PER_SEC   1000000000ul  /* Nano */


double ucs_get_cpu_clocks_per_sec();
unsigned ucs_get_short_time_shift();


/**
 * @return The current time, in UCS time units.
 */
static inline ucs_time_t ucs_get_time()
{
    return (ucs_time_t)ucs_arch_read_hres_clock();
}

/**
 * @return The clock value of a single second.
 */
static inline double ucs_time_sec_value()
{
    return ucs_get_cpu_clocks_per_sec();
}


/**
 * Convert seconds to UCS time units.
 */
static inline ucs_time_t ucs_time_from_sec(double sec)
{
    return sec * ucs_time_sec_value();
}

/**
 * Convert seconds to UCS time units.
 */
static inline ucs_time_t ucs_time_from_msec(double msec)<commit_msg>UCS/TIME: Explicit converton from double to integer type<commit_after>/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014.  ALL RIGHTS RESERVED.
*
* $COPYRIGHT$
* $HEADER$
*/

#ifndef UCS_TIME_H
#define UCS_TIME_H

#include <ucs/sys/sys.h>
#include <ucs/sys/math.h>


/**
 * UCS time units.
 * These are not necessarily aligned with metric time units.
 * MUST compare short time values with UCS_SHORT_TIME_CMP to handle wrap-around.
 */
typedef unsigned long long   ucs_time_t;

/**
 * Short time type
 * Used to represent short time intervals, and takes less memory.
 */
typedef uint32_t             ucs_short_time_t;

/**
 * Compare short time values
 */
#define UCS_SHORT_TIME_CMP  UCS_CIRCULAR_COMPARE32


#define UCS_TIME_INFINITY  ULLONG_MAX

#define UCS_MSEC_PER_SEC   1000ull       /* Milli */
#define UCS_USEC_PER_SEC   1000000ul     /* Micro */
#define UCS_NSEC_PER_SEC   1000000000ul  /* Nano */


double ucs_get_cpu_clocks_per_sec();
unsigned ucs_get_short_time_shift();


/**
 * @return The current time, in UCS time units.
 */
static inline ucs_time_t ucs_get_time()
{
    return (ucs_time_t)ucs_arch_read_hres_clock();
}

/**
 * @return The clock value of a single second.
 */
static inline double ucs_time_sec_value()
{
    return ucs_get_cpu_clocks_per_sec();
}


/**
 * Convert seconds to UCS time units.
 */
static inline ucs_time_t ucs_time_from_sec(double sec)
{
    return (ucs_time_t)(sec * ucs_time_sec_value() + 0.5);
}

/**
 * Convert seconds to UCS time units.
 */
static inline ucs_time_t ucs_time_from_msec(double msec)
{'fraction_non_alphanumeric': 0.09792967466316135, 'fraction_numerical': 0.0223463687150838, 'mean_word_length': 3.9096774193548387, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4077635', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1111, 'n_words': 291}