<commit_before>/*
 * $Id$
 * Copyright (C) 2009, Parrot Foundation.
 */

/*

=head1 NAME

config/gen/platform/generic/hires_timer.c

=head1 DESCRIPTION

High-resolution timer support

=head2 Functions

=over 4

=cut

*/

#include <time.h>

#define TIME_IN_NS(n) ((n).tv_sec * 1000*1000*1000 + (n).tv_nsec)

/*

=item C<UHUGEINTVAL Parrot_hires_get_time()>

Return a high-resolution number representing how long Parrot has been running.

=cut

*/

UHUGEINTVAL Parrot_hires_get_time()
{
    struct timespec ts;
    clock_gettime(CLOCK_BEST, &ts);
    return TIME_IN_NS(ts);
}<commit_msg>[config] Verify clock_getttime availability in generic platform, use gettimeofday if not<commit_after>/*
 * $Id$
 * Copyright (C) 2009, Parrot Foundation.
 */

/*

=head1 NAME

config/gen/platform/generic/hires_timer.c

=head1 DESCRIPTION

High-resolution timer support

=head2 Functions

=over 4

=cut

*/

#include "parrot/has_header.h"
#ifdef PARROT_HAS_HEADER_UNISTD
#include    <unistd.h>
#endif

#include <time.h>

#define TIME_IN_NS(n) ((n).tv_sec * 1000*1000*1000 + (n).tv_nsec)

/*

=item C<UHUGEINTVAL Parrot_hires_get_time()>

Return a high-resolution number representing how long Parrot has been running.

=cut

*/

UHUGEINTVAL Parrot_hires_get_time()
{
    struct timespec ts;
    #if _POSIX_TIMERS
    clock_gettime(CLOCK_BEST, &ts);
    #else
    struct timeval  tv;
    gettimeofday(&tv, NULL);

    ts.tv_sec = tv.tv_sec;
    ts.tv_nsec = tv.tv_usec * 1000;
    #endif
    return TIME_IN_NS(ts);
}
{'fraction_non_alphanumeric': 0.12008005336891261, 'fraction_numerical': 0.02935290193462308, 'mean_word_length': 4.033557046979865, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6707285', 'n_tokens_mistral': 646, 'n_tokens_neox': 590, 'n_words': 133}