<commit_before>/*
 * Core Estimator
 * CPU core estimation timing attack using web workers
 * 2014-02-27
 * 
 * Copyright ΩF:∅ Working Group contributors
 * License: X11/MIT
 *   See LICENSE.md
 */

/*! @source https://github.com/oftn/core-estimator/blob/master/core-estimator.js */

(function() {
	"use strict";

	// Set up performance testing function
	var performance = self.performance || Date;
	if (!performance.now) {
		if (performance.webkitNow) {
			performance.now = performance.webkitNow;
		} else {
			performance.now = function() { return +new Date; };
		}
	}

	// Get the location of the currently running script
	var path = (function () {
		var
		  filename = "fileName"
		, stack = "stack"
		, stacktrace = stack + "trace"
		, loc
		, matcher = function (stack, matchedLoc) {
			loc = matchedLoc;
		}
		;

		try { 0(); } catch (ex) {
			if (filename in ex) { // Firefox
				loc = ex[filename];
			} else if (stacktrace in ex) { // Opera
				ex[stacktrace].replace(/called from line \d+, column \d+ in (.*):/gm, matcher);
			} else if (stack in ex) { // WebKit, Blink, and IE10
				ex[stack].replace(/at.*?\(?(\S+):\d+:\d+\)?$/g, matcher);
			}
			if (!loc) {
				throw new Error("Your browser does not currently support Core Estimator.");
			}
			return loc;
		}
	}());

	// Path to workload.js is derived from the path of the running script.
	var workload = path.replace(/\/[^\/]+$/, "/workload.js");

	var dom_implemented = !!navigator.cores;
	var previously_run = false;

	// Set navigator.cores to a sane value before getCores is ever run
	if (!dom_implemented) {
		/** @expose */ navigator.cores = 1;
	}

	/**
	 * navigator.getCores(callback)
	 *
	 * Performs the statistical test to determine the correct number of cores
	 * and calls its callback with the core number as its argument.
	 *
	 * @expose
	 **/
	navigator.getCores = function(_continue, options) {
		options = options || {};
		if (!('use_cache' in options)) {
			options['use_cache'] = true;
		}

		// If we already have an answer, return early.
		if (dom_implemented || (options['use_cache'] && previously_run)) {
			_continue(navigator.cores);
			return;
		}<commit_msg>Add support for browsers without web workers<commit_after>/*
 * Core Estimator
 * CPU core estimation timing attack using web workers
 * 2014-02-27
 * 
 * Copyright ΩF:∅ Working Group contributors
 * License: X11/MIT
 *   See LICENSE.md
 */

/*! @source https://github.com/oftn/core-estimator/blob/master/core-estimator.js */

(function() {
	"use strict";

	// Set up performance testing function
	var performance = self.performance || Date;
	if (!performance.now) {
		if (performance.webkitNow) {
			performance.now = performance.webkitNow;
		} else {
			performance.now = function() { return +new Date; };
		}
	}

	// Get the location of the currently running script
	var path = (function () {
		var
		  filename = "fileName"
		, stack = "stack"
		, stacktrace = stack + "trace"
		, loc
		, matcher = function (stack, matchedLoc) {
			loc = matchedLoc;
		}
		;

		try { 0(); } catch (ex) {
			if (filename in ex) { // Firefox
				loc = ex[filename];
			} else if (stacktrace in ex) { // Opera
				ex[stacktrace].replace(/called from line \d+, column \d+ in (.*):/gm, matcher);
			} else if (stack in ex) { // WebKit, Blink, and IE10
				ex[stack].replace(/at.*?\(?(\S+):\d+:\d+\)?$/g, matcher);
			}
			if (!loc) {
				throw new Error("Your browser does not currently support Core Estimator.");
			}
			return loc;
		}
	}());

	// Path to workload.js is derived from the path of the running script.
	var workload = path.replace(/\/[^\/]+$/, "/workload.js");

	var dom_implemented = !!navigator.cores;
	var previously_run = false;

	// Set navigator.cores to a sane value before getCores is ever run
	if (!dom_implemented) {
		/** @expose */ navigator.cores = 1;
		if (typeof Worker === "undefined") {
			// Web workers not supported, effectively single-core
			dom_implemented = true;
		}
	}

	/**
	 * navigator.getCores(callback)
	 *
	 * Performs the statistical test to determine the correct number of cores
	 * and calls its callback with the core number as its argument.
	 *
	 * @expose
	 **/
	navigator.getCores = function(_continue, options) {
		options = options || {};
		if (!('use_cache' in options)) {
			options['use_cache'] = true;
		}

		// If we already have an answer, return early.
		if (dom_implemented || (options['use_cache'] && previously_run)) {
			_continue(navigator.cores);
			return;
		}
{'fraction_non_alphanumeric': 0.14787472035794183, 'fraction_numerical': 0.006263982102908278, 'mean_word_length': 3.090576395242452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4693006', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1431, 'n_words': 440}