<commit_before>
// Dependencies
var assert = require('assert');
var sinon = require('sinon');

// Lib
var DIR = process.cwd() + (process.env.MOCHA_COV ? '/lib-cov' : '/lib');
var Timer = require(DIR + '/Timer');

// ----------

describe('lib/Timer', function() {

    var HRTIME_AVAIL = 'hrtime' in process;

    var subject;

    beforeEach(function() {

        sinon.stub(Date, 'now').returns(1000000000000);
        if(HRTIME_AVAIL) {
            sinon.stub(process, 'hrtime').returns([ 100000000, 0 ]);
        }

        subject = new Timer('event');
    });

    afterEach(function() {

        Timer.prototype.USE_HRTIME = HRTIME_AVAIL;

        Date.now.restore();
        if(HRTIME_AVAIL) {
            process.hrtime.restore();
        }
    });

    // ----------

    describe('#constructor()', function() {

        it('should store name and start time using Date.now()', function() {

            Timer.prototype.USE_HRTIME = false;
            subject = new Timer('event');

            subject.data.name.should.equal('event');
            subject.startTime.should.equal(1000000000000);
        });

        if(HRTIME_AVAIL) {
            it('should store name and start time using process.hrtime()', function() {

                Timer.prototype.USE_HRTIME = true;
                subject = new Timer('event');

                subject.data.name.should.equal('event');<commit_msg>use sinon sandbox<commit_after>
// Dependencies
var assert = require('assert');
var Sinon = require('sinon');

// Lib
var DIR = process.cwd() + (process.env.MOCHA_COV ? '/lib-cov' : '/lib');
var Timer = require(DIR + '/Timer');

// ----------

describe('lib/Timer', function() {

    var HRTIME_AVAIL = 'hrtime' in process;

    var sinon, subject;

    beforeEach(function() {

        sinon = Sinon.sandbox.create({useFakeTimers: false});

        sinon.stub(Date, 'now').returns(1000000000000);
        if(HRTIME_AVAIL) {
            sinon.stub(process, 'hrtime').returns([ 100000000, 0 ]);
        }

        subject = new Timer('event');
    });

    afterEach(function() {

        Timer.prototype.USE_HRTIME = HRTIME_AVAIL;

        sinon.restore();
    });

    // ----------

    describe('#constructor()', function() {

        it('should store name and start time using Date.now()', function() {

            Timer.prototype.USE_HRTIME = false;
            subject = new Timer('event');

            subject.data.name.should.equal('event');
            subject.startTime.should.equal(1000000000000);
        });

        if(HRTIME_AVAIL) {
            it('should store name and start time using process.hrtime()', function() {

                Timer.prototype.USE_HRTIME = true;
                subject = new Timer('event');

                subject.data.name.should.equal('event');
{'fraction_non_alphanumeric': 0.16344086021505377, 'fraction_numerical': 0.025806451612903226, 'mean_word_length': 2.171590909090909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, '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': '2606261', 'n_tokens_mistral': 918, 'n_tokens_neox': 825, 'n_words': 161}