How to use endMeasure method in Best

Best JavaScript code snippet using best

index.js

Source:index.js Github

copy

Full Screen

...30];31function startMeasure(baseName) {32 performance.mark(`${baseName}-start`);33}34function endMeasure(baseName) {35 if (atom.inDevMode()) {36 performance.mark(`${baseName}-end`);37 performance.measure(baseName, `${baseName}-start`, `${baseName}-end`);38 // eslint-disable-next-line no-console39 console.log(`${baseName} took: `, performance.getEntriesByName(baseName)[0].duration);40 performance.clearMarks(`${baseName}-end`);41 performance.clearMeasures(baseName);42 }43 performance.clearMarks(`${baseName}-start`);44}45function createRange(editor, data) {46 if (!Object.hasOwnProperty.call(data, 'line') && !Object.hasOwnProperty.call(data, 'column')) {47 // data.line & data.column might be undefined for non-fatal invalid rules,48 // e.g.: "block-no-empty": "foo"49 // Return `false` so Linter will ignore the range50 return false;51 }52 return rangeFromLineNumber(editor, data.line - 1, data.column - 1);53}54export function activate() {55 startMeasure('linter-stylelint: Activation');56 require('atom-package-deps').install('linter-stylelint');57 subscriptions = new CompositeDisposable();58 subscriptions.add(atom.config.observe('linter-stylelint.useStandard', (value) => {59 useStandard = value;60 }));61 subscriptions.add(atom.config.observe('linter-stylelint.disableWhenNoConfig', (value) => {62 disableWhenNoConfig = value;63 }));64 subscriptions.add(atom.config.observe('linter-stylelint.showIgnored', (value) => {65 showIgnored = value;66 }));67 endMeasure('linter-stylelint: Activation');68}69export function deactivate() {70 subscriptions.dispose();71}72function generateHTMLMessage(message) {73 if (!message.rule || message.rule === 'CssSyntaxError') {74 return escapeHTML()(message.text);75 }76 const ruleParts = message.rule.split('/');77 let url;78 if (ruleParts.length === 1) {79 // Core rule80 url = `http://stylelint.io/user-guide/rules/${ruleParts[0]}`;81 } else {82 // Plugin rule83 const pluginName = ruleParts[0];84 // const ruleName = ruleParts[1];85 switch (pluginName) {86 case 'plugin':87 url = 'https://github.com/AtomLinter/linter-stylelint/tree/master/docs/noRuleNamespace.md';88 break;89 default:90 url = 'https://github.com/AtomLinter/linter-stylelint/tree/master/docs/linkingNewRule.md';91 }92 }93 // Escape any HTML in the message, and replace the rule ID with a link94 return escapeHTML()(message.text).replace(95 `(${message.rule})`, `(<a href="${url}">${message.rule}</a>)`96 );97}98const parseResults = (editor, options, results, filePath) => {99 startMeasure('linter-stylelint: Parsing results');100 if (options.code !== editor.getText()) {101 // The editor contents have changed since the lint was requested, tell102 // Linter not to update the results103 endMeasure('linter-stylelint: Parsing results');104 endMeasure('linter-stylelint: Lint');105 return null;106 }107 if (!results) {108 endMeasure('linter-stylelint: Parsing results');109 endMeasure('linter-stylelint: Lint');110 return [];111 }112 const invalidOptions = results.invalidOptionWarnings.map(msg => ({113 type: 'Error',114 severity: 'error',115 text: msg.text,116 filePath117 }));118 const warnings = results.warnings.map((warning) => {119 // Stylelint only allows 'error' and 'warning' as severity values120 const severity = !warning.severity || warning.severity === 'error' ? 'Error' : 'Warning';121 return {122 type: severity,123 severity: severity.toLowerCase(),124 html: generateHTMLMessage(warning),125 filePath,126 range: createRange(editor, warning)127 };128 });129 const deprecations = results.deprecations.map(deprecation => ({130 type: 'Warning',131 severity: 'warning',132 html: `${escapeHTML()(deprecation.text)} (<a href="${deprecation.reference}">reference</a>)`,133 filePath134 }));135 const ignored = [];136 if (showIgnored && results.ignored) {137 ignored.push({138 type: 'Warning',139 severity: 'warning',140 text: 'This file is ignored',141 filePath142 });143 }144 const toReturn = []145 .concat(invalidOptions)146 .concat(warnings)147 .concat(deprecations)148 .concat(ignored);149 endMeasure('linter-stylelint: Parsing results');150 endMeasure('linter-stylelint: Lint');151 return toReturn;152};153const runStylelint = async (editor, options, filePath) => {154 startMeasure('linter-stylelint: Stylelint');155 let data;156 try {157 data = await stylelint().lint(options);158 } catch (error) {159 endMeasure('linter-stylelint: Stylelint');160 // Was it a code parsing error?161 if (error.line) {162 endMeasure('linter-stylelint: Lint');163 return [{164 type: 'Error',165 severity: 'error',166 text: error.reason || error.message,167 filePath,168 range: createRange(editor, error)169 }];170 }171 // If we got here, stylelint found something really wrong with the172 // configuration, such as extending an invalid configuration173 atom.notifications.addError('Unable to run stylelint', {174 detail: error.reason || error.message,175 dismissable: true176 });177 endMeasure('linter-stylelint: Lint');178 return [];179 }180 endMeasure('linter-stylelint: Stylelint');181 const results = data.results.shift();182 return parseResults(editor, options, results, filePath);183};184export function provideLinter() {185 return {186 name: 'stylelint',187 grammarScopes: baseScopes,188 scope: 'file',189 lintOnFly: true,190 lint: async (editor) => {191 startMeasure('linter-stylelint: Lint');192 const scopes = editor.getLastCursor().getScopeDescriptor().getScopesArray();193 const filePath = editor.getPath();194 const text = editor.getText();195 if (!text) {196 endMeasure('linter-stylelint: Lint');197 return [];198 }199 // Require stylelint-config-standard if it hasn't already been loaded200 if (!presetConfig && useStandard) {201 presetConfig = require('stylelint-config-standard');202 }203 // Setup base config if useStandard() is true204 const defaultConfig = {205 rules: {}206 };207 // Base the config in the project directory208 let [configBasedir] = atom.project.relativizePath(filePath);209 if (configBasedir === null) {210 // Falling back to the file directory if no project is found211 configBasedir = dirname(filePath);212 }213 const rules = useStandard ? assignDeep()({}, presetConfig) : defaultConfig;214 const options = {215 code: text,216 codeFilename: filePath,217 config: rules,218 configBasedir219 };220 if (scopes.includes('source.css.scss') || scopes.includes('source.scss')) {221 options.syntax = 'scss';222 }223 if (scopes.includes('source.css.less') || scopes.includes('source.less')) {224 options.syntax = 'less';225 }226 if (scopes.includes('source.css.postcss.sugarss')) {227 options.syntax = 'sugarss';228 // `stylelint-config-standard` isn't fully compatible with SugarSS229 // See here for details:230 // https://github.com/stylelint/stylelint-config-standard#using-the-config-with-sugarss-syntax231 options.config.rules['block-closing-brace-empty-line-before'] = null;232 options.config.rules['block-closing-brace-newline-after'] = null;233 options.config.rules['block-closing-brace-newline-before'] = null;234 options.config.rules['block-closing-brace-space-before'] = null;235 options.config.rules['block-opening-brace-newline-after'] = null;236 options.config.rules['block-opening-brace-space-after'] = null;237 options.config.rules['block-opening-brace-space-before'] = null;238 options.config.rules['declaration-block-semicolon-newline-after'] = null;239 options.config.rules['declaration-block-semicolon-space-after'] = null;240 options.config.rules['declaration-block-semicolon-space-before'] = null;241 options.config.rules['declaration-block-trailing-semicolon'] = null;242 options.config.rules['declaration-block-trailing-semicolon'] = null;243 }244 startMeasure('linter-stylelint: Create Linter');245 const stylelintLinter = await stylelint().createLinter();246 endMeasure('linter-stylelint: Create Linter');247 startMeasure('linter-stylelint: Config');248 let foundConfig;249 try {250 foundConfig = await stylelintLinter.getConfigForFile(filePath);251 } catch (error) {252 if (!/No configuration provided for .+/.test(error.message)) {253 endMeasure('linter-stylelint: Config');254 // If we got here, stylelint failed to parse the configuration255 // there's no point of re-linting if useStandard is true, because the256 // user does not have the complete set of desired rules parsed257 atom.notifications.addError('Unable to parse stylelint configuration', {258 detail: error.message,259 dismissable: true260 });261 endMeasure('linter-stylelint: Lint');262 return [];263 }264 }265 endMeasure('linter-stylelint: Config');266 if (foundConfig) {267 options.config = assignDeep()(rules, foundConfig.config);268 options.configBasedir = dirname(foundConfig.filepath);269 }270 if (!foundConfig && disableWhenNoConfig) {271 endMeasure('linter-stylelint: Lint');272 return [];273 }274 startMeasure('linter-stylelint: Check ignored');275 let fileIsIgnored;276 try {277 fileIsIgnored = await stylelintLinter.isPathIgnored(filePath);278 } catch (error) {279 // Do nothing, configuration errors should have already been caught and thrown above280 }281 endMeasure('linter-stylelint: Check ignored');282 if (fileIsIgnored) {283 endMeasure('linter-stylelint: Lint');284 if (showIgnored) {285 return [{286 type: 'Warning',287 severity: 'warning',288 text: 'This file is ignored',289 filePath290 }];291 }292 return [];293 }294 const results = await runStylelint(editor, options, filePath);295 return results;296 }297 };...

Full Screen

Full Screen

sampler_spec.js

Source:sampler_spec.js Github

copy

Full Screen

...278 beginMeasure() {279 ListWrapper.push(this._log, ['beginMeasure']);280 return PromiseWrapper.resolve(null);281 }282 endMeasure(restart) {283 var measureValues = isPresent(this._endMeasure) ? this._endMeasure() : {};284 ListWrapper.push(this._log, ['endMeasure', restart, measureValues]);285 return PromiseWrapper.resolve(measureValues);286 }287}288class MockReporter extends Reporter {289 _log:List;290 constructor(log = null) {291 super();292 if (isBlank(log)) {293 log = [];294 }295 this._log = log;296 }297 reportMeasureValues(values):Promise {...

Full Screen

Full Screen

helpers.js

Source:helpers.js Github

copy

Full Screen

...11 performance.clearMarks(markName);12 }13 performance.mark(markName);14}15export function endMeasure(baseName) {16 if (atom.inDevMode()) {17 performance.mark(`${baseName}-end`);18 performance.measure(baseName, `${baseName}-start`, `${baseName}-end`);19 const duration = Math.round(performance.getEntriesByName(baseName)[0].duration * 10000) / 10000;20 // eslint-disable-next-line no-console21 console.log(`${baseName} took ${duration} ms`);22 performance.clearMarks(`${baseName}-end`);23 performance.clearMeasures(baseName);24 }25 performance.clearMarks(`${baseName}-start`);26}27export function createRange(editor, data) {28 if (!data ||29 (!Object.hasOwnProperty.call(data, 'line') && !Object.hasOwnProperty.call(data, 'column'))30 ) {31 // data.line & data.column might be undefined for non-fatal invalid rules,32 // e.g.: "block-no-empty": "foo"33 // Return a range encompassing the first line of the file34 return generateRange(editor);35 }36 return generateRange(editor, data.line - 1, data.column - 1);37}38const parseResults = (editor, results, filePath, showIgnored) => {39 startMeasure('linter-stylelint: Parsing results');40 if (!results) {41 endMeasure('linter-stylelint: Parsing results');42 endMeasure('linter-stylelint: Lint');43 return [];44 }45 const invalidOptions = results.invalidOptionWarnings.map(msg => ({46 severity: 'error',47 excerpt: msg.text,48 location: {49 file: filePath,50 position: createRange(editor)51 }52 }));53 const warnings = results.warnings.map((warning) => {54 // Stylelint only allows 'error' and 'warning' as severity values55 const severity = !warning.severity || warning.severity === 'error' ? 'Error' : 'Warning';56 const message = {57 severity: severity.toLowerCase(),58 excerpt: warning.text,59 location: {60 file: filePath,61 position: createRange(editor, warning)62 }63 };64 const ruleParts = warning.rule.split('/');65 if (ruleParts.length === 1) {66 // Core rule67 message.url = `http://stylelint.io/user-guide/rules/${ruleParts[0]}`;68 } else {69 // Plugin rule70 const pluginName = ruleParts[0];71 // const ruleName = ruleParts[1];72 const linterStylelintURL = 'https://github.com/AtomLinter/linter-stylelint/tree/master/docs';73 switch (pluginName) {74 case 'plugin':75 message.url = `${linterStylelintURL}/noRuleNamespace.md`;76 break;77 default:78 message.url = `${linterStylelintURL}/linkingNewRule.md`;79 }80 }81 return message;82 });83 const deprecations = results.deprecations.map(deprecation => ({84 severity: 'warning',85 excerpt: deprecation.text,86 url: deprecation.reference,87 location: {88 file: filePath,89 position: createRange(editor)90 }91 }));92 const ignored = [];93 if (showIgnored && results.ignored) {94 ignored.push({95 severity: 'warning',96 excerpt: 'This file is ignored',97 location: {98 file: filePath,99 position: createRange(editor)100 }101 });102 }103 const toReturn = []104 .concat(invalidOptions)105 .concat(warnings)106 .concat(deprecations)107 .concat(ignored);108 endMeasure('linter-stylelint: Parsing results');109 endMeasure('linter-stylelint: Lint');110 return toReturn;111};112export const runStylelint = async (editor, stylelintOptions, filePath, settings) => {113 startMeasure('linter-stylelint: Stylelint');114 let data;115 try {116 data = await stylelint.lint(stylelintOptions);117 } catch (error) {118 endMeasure('linter-stylelint: Stylelint');119 // Was it a code parsing error?120 if (error.line) {121 endMeasure('linter-stylelint: Lint');122 return [{123 severity: 'error',124 excerpt: error.reason || error.message,125 location: {126 file: filePath,127 position: createRange(editor, error)128 }129 }];130 }131 // If we got here, stylelint found something really wrong with the132 // configuration, such as extending an invalid configuration133 atom.notifications.addError('Unable to run stylelint', {134 detail: error.reason || error.message,135 dismissable: true136 });137 endMeasure('linter-stylelint: Lint');138 return [];139 }140 endMeasure('linter-stylelint: Stylelint');141 const results = data.results.shift();142 if (stylelintOptions.code !== editor.getText()) {143 // The editor contents have changed since the lint was requested, tell144 // Linter not to update the results145 endMeasure('linter-stylelint: Lint');146 return null;147 }148 return parseResults(editor, results, filePath, settings.showIgnored);149};150export function getDefaultConfig(syntax, filePath) {151 const defaultConfig = assignDeep({}, presetConfig);152 if (syntax === 'sugarss') {153 // `stylelint-config-standard` isn't fully compatible with SugarSS154 // See here for details:155 // https://github.com/stylelint/stylelint-config-standard#using-the-config-with-sugarss-syntax156 defaultConfig.rules['block-closing-brace-empty-line-before'] = null;157 defaultConfig.rules['block-closing-brace-newline-after'] = null;158 defaultConfig.rules['block-closing-brace-newline-before'] = null;159 defaultConfig.rules['block-closing-brace-space-before'] = null;...

Full Screen

Full Screen

LineSliceGrid.js

Source:LineSliceGrid.js Github

copy

Full Screen

1Ext.define('CpsiMapview.view.lineSliceGridExample.LineSliceGrid', {2 extend: 'Ext.grid.Panel',3 xtype: 'cmv_line_slice_grid',4 requires: [5 'CpsiMapview.plugin.LineSliceHighlight'6 ],7 plugins: [{8 ptype: 'cmv_line_slice_highlight'9 }],10 columns: [11 {12 text: 'From',13 dataIndex: 'startMeasure',14 renderer: function(val) {15 return val.toFixed(1) + ' m';16 }17 },18 {19 text: 'To',20 dataIndex: 'endMeasure',21 renderer: function(val) {22 return val.toFixed(1) + ' m';23 }24 },25 {26 text: 'Text',27 dataIndex: 'text'28 }29 ],30 listeners: {31 itemclick: function (_, record) {32 var highlighter = this.getPlugin('cmv_line_slice_highlight');33 highlighter.highlightSlice(this.feature.getGeometry(), record.data.startMeasure, record.data.endMeasure);34 }35 },36 initComponent: function () {37 var map = BasiGX.util.Map.getMapComponent().map;38 var store = Ext.create('Ext.data.Store', {39 data: [40 {startMeasure: 0, endMeasure: 200, text: 'slice 1'},41 {startMeasure: 200, endMeasure: 1000, text: 'slice 2'},42 {startMeasure: 1100, endMeasure: 1800, text: 'slice 3'},43 {startMeasure: 1400, endMeasure: 4000, text: 'slice 4'},44 {startMeasure: 5000, endMeasure: 12000, text: 'slice 5'}45 ]46 });47 this.store = store;48 var geoJson = JSON.stringify({49 'type': 'Feature',50 'geometry': {51 'type': 'LineString',52 'coordinates': [53 [-965068.9613156476, 6917903.9768694835], [-963761.0112796988, 6918876.101896202],54 [-962187.936236463, 6919883.576923893], [-960915.3362014858, 6920608.25194381],55 [-959695.7611679661, 6920024.976927779], [-958264.0861286167, 6919176.576904461],56 [-957645.4611116138, 6918893.776896688], [-961533.9612184886, 6918116.076875313],57 [-964344.28629573, 6914528.051776697], [-965387.1113243919, 6915853.676813131]58 ]59 },60 'properties': null61 });62 this.feature = (new ol.format.GeoJSON()).readFeature(geoJson, {63 featureProjection: 'EPSG:3857',64 dataProjection: 'EPSG:3857'65 });66 var layer = new ol.layer.Vector({67 source: new ol.source.Vector({68 features: [this.feature]69 }),70 map: map,71 style: new ol.style.Style({72 stroke: new ol.style.Stroke({73 color: 'yellow',74 width: 275 })76 }),77 visible: false78 });79 this.callParent(arguments);80 var highlighter = this.getPlugin('cmv_line_slice_highlight');81 highlighter.setStyle(new ol.style.Style({82 stroke: new ol.style.Stroke({83 color: 'blue',84 width: 285 })86 }));87 this.up('cmv_minimizable_window').on('show', function () {88 layer.setVisible(true);89 map.render();90 });91 this.up('cmv_minimizable_window').on('close', function () {92 layer.setVisible(false);93 highlighter.removeHighlight();94 map.render();95 });96 }...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

1//2// Created by Mingliang Chen on 17/12/24. Merry Christmas3// illuspas[a]gmail.com4// Copyright (c) 2018 Nodemedia. All rights reserved.5//6const OS = require('os');7const Package = require("../../package.json");8function cpuAverage() {9 //Initialise sum of idle and time of cores and fetch CPU info10 let totalIdle = 0, totalTick = 0;11 let cpus = OS.cpus();12 //Loop through CPU cores13 for (let i = 0, len = cpus.length; i < len; i++) {14 //Select CPU core15 let cpu = cpus[i];16 //Total up the time in the cores tick17 for (type in cpu.times) {18 totalTick += cpu.times[type];19 }20 //Total up the idle time of the core21 totalIdle += cpu.times.idle;22 }23 //Return the average Idle and Tick times24 return { idle: totalIdle / cpus.length, total: totalTick / cpus.length };25}26function percentageCPU() {27 return new Promise(function (resolve, reject) {28 let startMeasure = cpuAverage();29 setTimeout(() => {30 let endMeasure = cpuAverage();31 //Calculate the difference in idle and total time between the measures32 let idleDifference = endMeasure.idle - startMeasure.idle;33 let totalDifference = endMeasure.total - startMeasure.total;34 //Calculate the average percentage CPU usage35 let percentageCPU = 100 - ~~(100 * idleDifference / totalDifference);36 resolve(percentageCPU);37 }, 100);38 });39}40function getSessionsInfo(sessions) {41 let info = {42 inbytes: 0,43 outbytes: 0,44 rtmp: 0,45 http: 0,46 ws: 0,47 };48 for (let session of sessions.values()) {49 if (session.TAG === 'relay') continue;50 let socket = session.TAG === 'rtmp' ? session.socket : session.req.socket;51 info.inbytes += socket.bytesRead;52 info.outbytes += socket.bytesWritten;53 info.rtmp += session.TAG === 'rtmp' ? 1 : 0;54 info.http += session.TAG === 'http-flv' ? 1 : 0;55 info.ws += session.TAG === 'websocket-flv' ? 1 : 0;56 }57 return info;58}59function getInfo(req, res, next) {60 let s = this.sessions;61 percentageCPU().then((cpuload) => {62 let sinfo = getSessionsInfo(s);63 let info = {64 os: {65 arch: OS.arch(),66 platform: OS.platform(),67 release: OS.release(),68 },69 cpu: {70 num: OS.cpus().length,71 load: cpuload,72 model: OS.cpus()[0].model,73 speed: OS.cpus()[0].speed,74 },75 mem: {76 totle: OS.totalmem(),77 free: OS.freemem()78 },79 net: {80 inbytes: this.stat.inbytes + sinfo.inbytes,81 outbytes: this.stat.outbytes + sinfo.outbytes,82 },83 nodejs: {84 uptime: Math.floor(process.uptime()),85 version: process.version,86 mem: process.memoryUsage()87 },88 clients: {89 accepted: this.stat.accepted,90 active: this.sessions.size - this.idlePlayers.size,91 idle: this.idlePlayers.size,92 rtmp: sinfo.rtmp,93 http: sinfo.http,94 ws: sinfo.ws95 },96 version: Package.version97 };98 res.json(info);99 });100}...

Full Screen

Full Screen

measure-interval-templates.js

Source:measure-interval-templates.js Github

copy

Full Screen

1import {Format, Difference} from '../../utilities/date-time.js';2import {Timing} from '../../utilities/timing.js';3import {roundToTwoDecimals} from '../../utilities/number.js';4const makeHtml = (component) => (5`6<h1><gwbw-icon name="straighten"></gwbw-icon> Measure Interval</h1>7<div class="more-info-header">8 <h1 class="invisible"><gwbw-icon name="straighten"></gwbw-icon></h1>9 ${' '}<h3>${component.watch.name}</h3>10</div>11<h2>12 <span class="session-days-range nowrap" title="${Format.dateAndTime(component.startMeasure.targetMoment) + ' - ' + Format.dateAndTime(component.endMeasure.targetMoment)}">13 ${Format.dateRange(component.startMeasure.targetMoment, component.endMeasure.targetMoment)}14 </span>15 <small class="session-duration-in-days nowrap" title="${Format.durationLong(component.endMeasure.targetMoment, component.startMeasure.targetMoment)}">16 (${roundToTwoDecimals(Difference.days(component.startMeasure.targetMoment, component.endMeasure.targetMoment))} days)17 </small>18</h2>19<h3 class="average ${getClasses(component)}">20 Average:${` `}21 <span class="rate ${getRate(component) >= 0 ? `fast` : `slow`}">${getRate(component)} seconds/day</span>22</h3>23<div class="good-bad-message ${getClasses(component)}">24 <h4 class="good"><gwbw-icon name="thumb_up"></gwbw-icon> Good watch</h4>25 <h4 class="bad"><gwbw-icon name="thumb_down"></gwbw-icon> Bad watch</h4>26</div>27<hr>28<div class="positions-detail">29 <gwbw-positions-detail30 watchid="${component.watch._id}"31 startmeasureid="${component.startMeasure._id}"32 endmeasureid="${component.endMeasure._id}"33 goodtoleranceplus="${component.watch.goodTolerancePlus}"34 goodtoleranceminus="${component.watch.goodToleranceMinus}"35 ></gwbw-positions-detail>36</div>37<a class="big-link" href="javascript:history.back();">Back to Measures</button>38`39);40const makeCss = (component) => (41`42<style>43@import "styles/global-styles.css";44h1 gwbw-icon { transform: rotate(90deg); }45.session-days-range { margin-right: .2em; }46p { margin-top: -1.2em; }47.average.good-watch { color: var(--green); }48.average.bad-watch { color: var(--red); }49.rate.fast:before { content: "+"; }50.good-bad-message > * { display: none; margin-top: -1.5em; }51.good-bad-message.good-watch .good { display: block; color: var(--green); }52.good-bad-message.bad-watch .bad { display: block; color: var(--red); }53.positions-detail { margin-bottom: 2em; }54</style>55`56);57const getRate = component => {58 return Timing.rate(59 component.startMeasure.targetMoment, component.startMeasure.moment,60 component.endMeasure.targetMoment, component.endMeasure.moment61 );62};63const getClasses = component => {64 const isGood =65 getRate(component) <= component.watch.goodTolerancePlus &&66 getRate(component) >= -1 * component.watch.goodToleranceMinus;67 return isGood ? `good-watch` : `bad-watch`;68};69export const makeTemplate = (component) => {70 return makeCss(component) + makeHtml(component);...

Full Screen

Full Screen

UIProfiler.js

Source:UIProfiler.js Github

copy

Full Screen

...22 startMeasure: function(markName) {23 startMeasure(markName);24 },25 endMeasure: function(markName) {26 endMeasure(markName);27 },28 getMeasurements: function(markName) {29 var time = getMeasurements(markName);30 return time.duration;31 }32 };33 };34 return {35 getInstance: function() {36 if (window.performance == null) {37 throw new Error(notSupportedMessage);38 }39 if (!instance) {40 instance = createTimer();...

Full Screen

Full Screen

cpu_usage.js

Source:cpu_usage.js Github

copy

Full Screen

1/* cpu usage2https://gist.github.com/bag-man/55708093*/4var os = R.node.os;5//Create function to get CPU information6function cpuAverage() {7 //Initialise sum of idle and time of cores and fetch CPU info8 var totalIdle = 0, totalTick = 0;9 var cpus = os.cpus();10 //Loop through CPU cores11 for(var i = 0, len = cpus.length; i < len; i++) {12 //Select CPU core13 var cpu = cpus[i];14 //Total up the time in the cores tick15 for(type in cpu.times) totalTick += cpu.times[type];16 //Total up the idle time of the core17 totalIdle += cpu.times.idle;18 }19 //Return the average Idle and Tick times20 return {idle: totalIdle / cpus.length, total: totalTick / cpus.length};21}22//Grab first CPU Measure23var startMeasure = cpuAverage();24//Set delay for second Measure25R.service.timers.cpu_usage = setInterval(function() { 26 //Grab second Measure27 var endMeasure = cpuAverage(); 28 //Calculate the difference in idle and total time between the measures29 var idleDifference = endMeasure.idle - startMeasure.idle;30 var totalDifference = endMeasure.total - startMeasure.total;31 //Calculate the average percentage CPU usage32 var percentageCPU = 100 - ~~(100 * idleDifference / totalDifference);33 //Output result to console34 //console.log("\r" + percentageCPU + "% CPU Usage.");35 R.status.cpu_usage = percentageCPU;36 startMeasure = endMeasure;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var best = require('best');2var bestObj = new best.Best();3bestObj.startMeasure();4var sum = 0;5for (var i = 0; i < 1000000; i++) {6 sum += 1;7}8bestObj.endMeasure();9console.log(bestObj.getMeasure());10var best = require('best');11var bestObj = new best.Best();12bestObj.startMeasure();13var sum = 0;14for (var i = 0; i < 1000000; i++) {15 sum += 1;16}17console.log(bestObj.getMeasure());18var best = require('best');19var bestObj = new best.Best();20bestObj.startMeasure();21var sum = 0;22for (var i = 0; i < 1000000; i++) {23 sum += 1;24}25console.log(bestObj.getMeasure());26var best = require('best');27var bestObj = new best.Best();28bestObj.startMeasure();29var sum = 0;30for (var i = 0; i < 1000000; i++) {31 sum += 1;32}33bestObj.endMeasure();34console.log(bestObj.getMeasure());35var best = require('best');36var bestObj = new best.Best();37bestObj.startMeasure();38var sum = 0;39for (var i = 0; i < 1000000; i++) {40 sum += 1;41}42console.log(bestObj.getMeasure());43var best = require('best');44var bestObj = new best.Best();45bestObj.startMeasure();46var sum = 0;47for (var i = 0; i < 1000000; i++) {48 sum += 1;49}50console.log(bestObj.getMeasure());51var best = require('best');52var bestObj = new best.Best();53bestObj.startMeasure();54var sum = 0;55for (var i = 0; i < 1000000; i++) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var b = new BestPractice();2b.endMeasure("test");3var b = new BestPractice();4b.endMeasure("test");5var b = new BestPractice();6b.endMeasure("test");7var b = new BestPractice();8b.endMeasure("test");9var b = new BestPractice();10b.endMeasure("test");11var b = new BestPractice();12b.endMeasure("test");13var b = new BestPractice();14b.endMeasure("test");15var b = new BestPractice();16b.endMeasure("test");17var b = new BestPractice();18b.endMeasure("test");19var b = new BestPractice();20b.endMeasure("test");21var b = new BestPractice();22b.endMeasure("test");23var b = new BestPractice();24b.endMeasure("test");25var b = new BestPractice();26b.endMeasure("test");27var b = new BestPractice();28b.endMeasure("test");29var b = new BestPractice();30b.endMeasure("test");31var b = new BestPractice();32b.endMeasure("test");33var b = new BestPractice();34b.endMeasure("test");35var b = new BestPractice();36b.endMeasure("test");37var b = new BestPractice();38b.endMeasure("test");

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPractice = require('./BestPractice');2var bestPractice = new BestPractice();3bestPractice.startMeasure('test4');4bestPractice.endMeasure('test4');5var BestPractice = require('./BestPractice');6var bestPractice = new BestPractice();7bestPractice.startMeasure('test5');8bestPractice.endMeasure('test5');9var BestPractice = require('./BestPractice');10var bestPractice = new BestPractice();11bestPractice.startMeasure('test6');12bestPractice.endMeasure('test6');13var BestPractice = require('./BestPractice');14var bestPractice = new BestPractice();15bestPractice.startMeasure('test7');16bestPractice.endMeasure('test7');17var BestPractice = require('./BestPractice');18var bestPractice = new BestPractice();19bestPractice.startMeasure('test8');20bestPractice.endMeasure('test8');21var BestPractice = require('./BestPractice');22var bestPractice = new BestPractice();23bestPractice.startMeasure('test9');24bestPractice.endMeasure('test9');25var BestPractice = require('./BestPractice');26var bestPractice = new BestPractice();27bestPractice.startMeasure('test10');28bestPractice.endMeasure('test10');29var BestPractice = require('./BestPractice');30var bestPractice = new BestPractice();31bestPractice.startMeasure('test11');32bestPractice.endMeasure('test11');33var BestPractice = require('./BestPractice');34var bestPractice = new BestPractice();35bestPractice.startMeasure('test12');

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestPractice = require('./bestPractice.js');2var bp = new bestPractice();3bp.startMeasure();4bp.endMeasure();5function BestPractice() {6 this.startMeasure = function() {7 this.startTime = new Date().getTime();8 }9 this.endMeasure = function() {10 this.endTime = new Date().getTime();11 console.log('Time taken: ' + (this.endTime - this.startTime) + 'ms');12 }13}14module.exports = BestPractice;15var bestPractice = require('./bestPractice.js');16var bp = new bestPractice();17bp.timeTaken(function() {18 for (var i = 0; i < 1000000000; i++) {19 var a = i;20 }21});22function BestPractice() {23 this.timeTaken = function(callback) {24 var startTime = new Date().getTime();25 callback();26 var endTime = new Date().getTime();27 console.log('Time taken: ' + (endTime - startTime) + 'ms');28 }29}30module.exports = BestPractice;31var bestPractice = require('./bestPractice.js');32var bp = new bestPractice();33bp.timeTaken(function() {34 for (var i = 0; i < 1000000000; i++) {35 var a = i;36 }37});38function BestPractice() {39 this.timeTaken = function(callback) {40 var startTime = Date.now();41 callback();42 var endTime = Date.now();43 console.log('Time taken: ' + (endTime - startTime) + 'ms');44 }45}46module.exports = BestPractice;

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPractice = require('best-practice');2var bestPractice = new BestPractice();3var measure = bestPractice.startMeasure();4measure.endMeasure();5var BestPractice = require('best-practice');6var bestPractice = new BestPractice();7var measure = bestPractice.startMeasure();8measure.endMeasure();9var BestPractice = require('best-practice');10var bestPractice = new BestPractice();11var measure = bestPractice.startMeasure();12measure.endMeasure();13var BestPractice = require('best-practice');14var bestPractice = new BestPractice();15var measure = bestPractice.startMeasure();16measure.endMeasure();17var BestPractice = require('best-practice');18var bestPractice = new BestPractice();19var measure = bestPractice.startMeasure();20measure.endMeasure();21var BestPractice = require('best-practice');22var bestPractice = new BestPractice();23var measure = bestPractice.startMeasure();24measure.endMeasure();25var BestPractice = require('best-practice');26var bestPractice = new BestPractice();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPractice = require('./BestPractice');2var bestPractice = new BestPractice();3bestPractice.startMeasure('test4.js');4var a = 0;5for(var i = 0; i < 10000; i++){6a = a + i;7}8console.log('a: ' + a);9bestPractice.endMeasure('test4.js');10bestPractice.printMeasures();

Full Screen

Using AI Code Generation

copy

Full Screen

1var best = require('bestjs');2var B = new best.BestJS();3B.startMeasure();4var a = 0;5for (var i = 0; i < 1000000000; i++) {6 a++;7}

Full Screen

Using AI Code Generation

copy

Full Screen

1var bp = require('bestpractice');2var measure = bp.startMeasure('test');3var i=0;4while(i<10000000){5i++;6}7bp.endMeasure(measure);8var bp = require('bestpractice');9var measure = bp.startMeasure('test');10var i=0;11while(i<10000000){12i++;13}14bp.endMeasure(measure);15var bp = require('bestpractice');16var measure = bp.startMeasure('test');17var i=0;18while(i<10000000){19i++;20}21bp.endMeasure(measure);22var bp = require('bestpractice');23var measure = bp.startMeasure('test');24var i=0;25while(i<10000000){26i++;27}28bp.endMeasure(measure);29var bp = require('bestpractice');30var measure = bp.startMeasure('test');31var i=0;32while(i<10000000){33i++;34}35bp.endMeasure(measure);36var bp = require('bestpractice');37var measure = bp.startMeasure('test');38var i=0;39while(i<10000000){40i++;41}42bp.endMeasure(measure);43var bp = require('bestpractice');44var measure = bp.startMeasure('test');45var i=0;46while(i<10000000){47i++;48}49bp.endMeasure(measure);50var bp = require('bestpractice');51var measure = bp.startMeasure('test');52var i=0;53while(i<10000000){54i++;55}56bp.endMeasure(measure);57var bp = require('bestpractice');58var measure = bp.startMeasure('test');59var i=0;60while(i<10000000){61i++;62}63bp.endMeasure(measure);64var bp = require('bestpractice');65var measure = bp.startMeasure('test');66var i=0;67while(i<10000000){68i++;69}70bp.endMeasure(measure);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful