Skip to content

Commit d6fd189

Browse files
committed
Fix performance
1 parent 3d76f19 commit d6fd189

9 files changed

+10
-2
lines changed

cf/polyfills.js

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export const crypto = {
7070
})
7171
}
7272

73+
export const performance = globalThis.performance
74+
7375
export const process = {
7476
env: {}
7577
}

cf/src/connection.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { net } from '../polyfills.js'
44
import { tls } from '../polyfills.js'
55
import { crypto } from '../polyfills.js'
66
import Stream from 'node:stream'
7+
import { performance } from '../polyfills.js'
78

89
import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
910
import { Errors } from './errors.js'

cjs/src/connection.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const net = require('net')
22
const tls = require('tls')
33
const crypto = require('crypto')
44
const Stream = require('stream')
5+
const { performance } = require('perf_hooks')
56

67
const { stringify, handleValue, arrayParser, arraySerializer } = require('./types.js')
78
const { Errors } = require('./errors.js')

cjs/tests/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ t('subscribe', { timeout: 2 }, async() => {
20272027
await sql`insert into test (name) values ('Oh noes')`
20282028
await delay(10)
20292029
return [
2030-
'insert,Murray,1,,,update,Rothbard,1,,,update,Rothbard,2,,1,delete,,2,,,insert,Murray,2,,,update,Rothbard,2,Murray,2,delete,Rothbard,2,,',
2030+
'insert,Murray,1,,,update,Rothbard,1,,,update,Rothbard,2,,1,delete,,2,,,insert,Murray,2,,,update,Rothbard,2,Murray,2,delete,Rothbard,2,,', // eslint-disable-line
20312031
result.join(','),
20322032
await sql`drop table test`,
20332033
await sql`drop publication alltables`,

deno/src/connection.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { tls } from '../polyfills.js'
66
import crypto from 'https://deno.land/[email protected]/node/crypto.ts'
77
import Stream from 'https://deno.land/[email protected]/node/stream.ts'
88

9+
910
import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
1011
import { Errors } from './errors.js'
1112
import Result from './result.js'

deno/tests/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ t('subscribe', { timeout: 2 }, async() => {
20292029
await sql`insert into test (name) values ('Oh noes')`
20302030
await delay(10)
20312031
return [
2032-
'insert,Murray,1,,,update,Rothbard,1,,,update,Rothbard,2,,1,delete,,2,,,insert,Murray,2,,,update,Rothbard,2,Murray,2,delete,Rothbard,2,,',
2032+
'insert,Murray,1,,,update,Rothbard,1,,,update,Rothbard,2,,1,delete,,2,,,insert,Murray,2,,,update,Rothbard,2,Murray,2,delete,Rothbard,2,,', // eslint-disable-line
20332033
result.join(','),
20342034
await sql`drop table test`,
20352035
await sql`drop publication alltables`,

src/connection.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import net from 'net'
22
import tls from 'tls'
33
import crypto from 'crypto'
44
import Stream from 'stream'
5+
import { performance } from 'perf_hooks'
56

67
import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
78
import { Errors } from './errors.js'

transpile.cf.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ function transpile(x) {
3434
.replace('import crypto from \'crypto\'', 'import { crypto } from \'../polyfills.js\'')
3535
.replace('import os from \'os\'', 'import { os } from \'../polyfills.js\'')
3636
.replace('import fs from \'fs\'', 'import { fs } from \'../polyfills.js\'')
37+
.replace('import { performance } from \'perf_hooks\'', 'import { performance } from \'../polyfills.js\'')
3738
.replace(/ from '([a-z_]+)'/g, ' from \'node:$1\'')
3839
}

transpile.deno.js

+1
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,6 @@ function transpile(x, name, folder) {
8787
.replace('node:stream', std + 'node/stream.ts')
8888
.replace('import net from \'net\'', 'import { net } from \'../polyfills.js\'')
8989
.replace('import tls from \'tls\'', 'import { tls } from \'../polyfills.js\'')
90+
.replace('import { performance } from \'perf_hooks\'', '')
9091
.replace(/ from '([a-z_]+)'/g, ' from \'' + std + 'node/$1.ts\'')
9192
}

0 commit comments

Comments
 (0)