How to use the batch.requests function in batch

To help you get started, we’ve selected a few batch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikimedia / parsoid / lib / config / MWParserEnvironment.js View on Github external
var cpuOut = this._formatProfile(this.timeProfile);
	this.log('trace/time', 'Finished parse at ', endTime);

	var outLines = [];
	outLines.push("-".repeat(85));
	outLines.push("Recorded times (in ms) for various parse components");
	outLines.push("");
	outLines.push(cpuOut.buf);
	outLines.push("-".repeat(85));
	outLines.push(ioOut.buf);
	outLines.push("");
	outLines.push(formatLine('Total API requests', this.counts["io.requests"]));
	if (this.counts.batches) {
		outLines.push(formatLine('# non-batched API requests', this.counts["io.requests"] - this.counts.batches));
		outLines.push(formatLine('# batches', this.counts.batches));
		outLines.push(formatLine('# API requests in batches', this.counts["batch.requests"]));
	}
	outLines.push("-".repeat(85));
	outLines.push(formatLine('TOTAL PARSE TIME (1)', endTime - this.startTime));
	outLines.push(formatLine('TOTAL PARSOID CPU TIME (2)', cpuOut.total));
	outLines.push(formatLine('Un/over-accounted parse time: (1) - (2)', endTime - this.startTime - cpuOut.total));
	outLines.push("");
	var catOut = this._formatProfile(this.timeCategories, { printPercentage: true });
	outLines.push(catOut.buf);
	outLines.push("");
	outLines.push(formatLine('TOTAL M/W API (I/O, CPU, QUEUE) TIME', ioOut.total, 'Total time across concurrent MW API requests'));
	if (mwOut.total > 0) {
		outLines.push(formatLine('TOTAL M/W CPU TIME', mwOut.total, 'Total CPU time across concurrent MW API requests'));
	}
	outLines.push("-".repeat(85));

	console.warn(outLines.join("\n"));

batch

Simple async batch with concurrency control and progress reporting.

MIT
Latest version published 8 years ago

Package Health Score

74 / 100
Full package analysis

Popular batch functions