Skip to content

Commit

Permalink
Fix performance
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Jul 5, 2023
1 parent 3d76f19 commit d6fd189
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cf/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export const crypto = {
})
}

export const performance = globalThis.performance

export const process = {
env: {}
}
Expand Down
1 change: 1 addition & 0 deletions cf/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { net } from '../polyfills.js'
import { tls } from '../polyfills.js'
import { crypto } from '../polyfills.js'
import Stream from 'node:stream'
import { performance } from '../polyfills.js'

import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
import { Errors } from './errors.js'
Expand Down
1 change: 1 addition & 0 deletions cjs/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const net = require('net')
const tls = require('tls')
const crypto = require('crypto')
const Stream = require('stream')
const { performance } = require('perf_hooks')

const { stringify, handleValue, arrayParser, arraySerializer } = require('./types.js')
const { Errors } = require('./errors.js')
Expand Down
2 changes: 1 addition & 1 deletion cjs/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ t('subscribe', { timeout: 2 }, async() => {
await sql`insert into test (name) values ('Oh noes')`
await delay(10)
return [
'insert,Murray,1,,,update,Rothbard,1,,,update,Rothbard,2,,1,delete,,2,,,insert,Murray,2,,,update,Rothbard,2,Murray,2,delete,Rothbard,2,,',
'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
result.join(','),
await sql`drop table test`,
await sql`drop publication alltables`,
Expand Down
1 change: 1 addition & 0 deletions deno/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { tls } from '../polyfills.js'
import crypto from 'https://deno.land/[email protected]/node/crypto.ts'
import Stream from 'https://deno.land/[email protected]/node/stream.ts'


import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
import { Errors } from './errors.js'
import Result from './result.js'
Expand Down
2 changes: 1 addition & 1 deletion deno/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ t('subscribe', { timeout: 2 }, async() => {
await sql`insert into test (name) values ('Oh noes')`
await delay(10)
return [
'insert,Murray,1,,,update,Rothbard,1,,,update,Rothbard,2,,1,delete,,2,,,insert,Murray,2,,,update,Rothbard,2,Murray,2,delete,Rothbard,2,,',
'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
result.join(','),
await sql`drop table test`,
await sql`drop publication alltables`,
Expand Down
1 change: 1 addition & 0 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import net from 'net'
import tls from 'tls'
import crypto from 'crypto'
import Stream from 'stream'
import { performance } from 'perf_hooks'

import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
import { Errors } from './errors.js'
Expand Down
1 change: 1 addition & 0 deletions transpile.cf.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ function transpile(x) {
.replace('import crypto from \'crypto\'', 'import { crypto } from \'../polyfills.js\'')
.replace('import os from \'os\'', 'import { os } from \'../polyfills.js\'')
.replace('import fs from \'fs\'', 'import { fs } from \'../polyfills.js\'')
.replace('import { performance } from \'perf_hooks\'', 'import { performance } from \'../polyfills.js\'')
.replace(/ from '([a-z_]+)'/g, ' from \'node:$1\'')
}
1 change: 1 addition & 0 deletions transpile.deno.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ function transpile(x, name, folder) {
.replace('node:stream', std + 'node/stream.ts')
.replace('import net from \'net\'', 'import { net } from \'../polyfills.js\'')
.replace('import tls from \'tls\'', 'import { tls } from \'../polyfills.js\'')
.replace('import { performance } from \'perf_hooks\'', '')
.replace(/ from '([a-z_]+)'/g, ' from \'' + std + 'node/$1.ts\'')
}

0 comments on commit d6fd189

Please sign in to comment.