This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const net = require('net'); | |
let server; | |
if (process.argv[2] !== undefined) | |
server = process.argv[2]; | |
else { | |
console.error('specify server address/name'); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gdal = require('../node-gdal-async'); | |
const perf = require('perf_hooks').performance; | |
const PerformanceObserver = require('perf_hooks').PerformanceObserver; | |
const elu = perf.eventLoopUtilization(); | |
console.time('open'); | |
const dataset = gdal.open('admin.geojson'); | |
console.timeEnd('open'); | |
console.time('count'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* light-weight, called by IntersectionObserver */ | |
async function wind() { | |
/* scheduleLoad schedules loading of the data */ | |
windData = await scheduleLoad(windReq); | |
/* scheduleDisplay is an equivalent function | |
* that schedules DOM updates */ | |
await scheduleDisplay(windData); | |
} | |
/* create a promise that will be queued and return it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import * as wiki from './wiki.mjs'; | |
const result = {}; | |
const linksHereCache = {}; | |
(async function getPage(id, level) { | |
if (!linksHereCache[id]) | |
linksHereCache[id] = wiki.linksHere(id).then(links => linksHereCache[id] = links); | |
let links; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const parseline = require('./parseline'); | |
const rs = fs.createReadStream('allCountries.txt'); | |
const nl = '\n'.charCodeAt(0); | |
const tab = '\t'.charCodeAt(0); | |
function parseline(line, start) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseline2(line) { | |
const f0 = line.indexOf('\t'); | |
const f1 = line.indexOf('\t', f0 + 1); | |
const data1 = line.slice(f0 + 1, f1); | |
if (data1 && data1.match(/^Paris$/g)) | |
counter++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const parseline = require('./parseline'); | |
const rs = fs.createReadStream('allCountries.txt'); | |
let t0 = 0, t1 = 0; | |
(async () => { | |
console.time(__filename); | |
let remainder = ''; | |
for await (const buf of rs) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const rs = fs.createReadStream('allCountries.txt'); | |
const parseline = require('./parseline'); | |
console.time(__filename); | |
let remainder = ''; | |
rs.on('data', (buf) => { | |
const lines = (remainder + buf).split(/\r?\n/g); | |
remainder = lines.pop(); | |
for (const line of lines) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const es = require('event-stream'); | |
const parseline = require('./parseline'); | |
const rs = fs.createReadStream('allCountries.txt'); | |
console.time(__filename); | |
rs.pipe(es.split()).pipe(es.through(parseline)); | |
rs.on('close', () => console.timeEnd(__filename)); |