Skip to content

Commit

Permalink
Drop readlines/promises Dependency (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleoutIce authored Jan 15, 2024
2 parents a44b711 + 54d8476 commit 07a1487
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions src/cli/repl/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* @module
*/
import { RShell } from '../../r-bridge'
import readline from 'readline/promises'
import { bold } from '../../statistics'
import { prompt } from './prompt'
import { commandNames, getCommand, ReplOutput, standardReplOutput } from './commands'
import { ReadLineOptions } from 'node:readline'
import * as readline from 'node:readline'
import { splitAtEscapeSensitive } from '../../util/args'
import { executeRShellCommand } from './commands/execute'

Expand All @@ -21,7 +20,7 @@ export function replCompleter(line: string): [string[], string] {
return [replCompleterKeywords.filter(k => k.startsWith(line)), line]
}

export const DEFAULT_REPL_READLINE_CONFIGURATION: ReadLineOptions = {
export const DEFAULT_REPL_READLINE_CONFIGURATION: readline.ReadLineOptions = {
input: process.stdin,
output: process.stdout,
tabSize: 4,
Expand Down Expand Up @@ -81,8 +80,14 @@ export async function repl(shell = new RShell({ revive: 'always' }), rl = readli
// the incredible repl :D, we kill it with ':quit'
// eslint-disable-next-line no-constant-condition,@typescript-eslint/no-unnecessary-condition
while(true) {
const answer: string = await rl.question(prompt())

await replProcessAnswer(output, answer, shell)
await new Promise<void>((resolve, reject) => {
rl.question(prompt(), answer => {
rl.pause()
replProcessAnswer(output, answer, shell).then(() => {
rl.resume()
resolve()
}).catch(reject)
})
})
}
}
2 changes: 1 addition & 1 deletion src/cli/repl/server/messages/analysis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IdMessageBase, MessageDefinition } from './messages'
import { LAST_PER_FILE_STEP, StepResults } from '../../../../core'
import Joi from 'joi'
import * as Joi from 'joi'
import { ControlFlowInformation } from '../../../../util/cfg'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/cli/repl/server/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @module
*/
import Joi from 'joi'
import * as Joi from 'joi'
import { FlowrHelloResponseMessage } from './hello'
import { FileAnalysisRequestMessage, FileAnalysisResponseMessageJson } from './analysis'
import { ExecuteEndMessage, ExecuteIntermediateResponseMessage, ExecuteRequestMessage } from './repl'
Expand Down
2 changes: 1 addition & 1 deletion src/cli/repl/server/messages/repl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IdMessageBase, MessageDefinition } from './messages'
import Joi from 'joi'
import * as Joi from 'joi'

/**
* Request the execution of the given expression as a REPL statement.
Expand Down
2 changes: 1 addition & 1 deletion src/cli/repl/server/messages/slice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlicingCriteria } from '../../../../slicing'
import { LAST_PER_FILE_STEP, LAST_STEP, StepResults } from '../../../../core'
import { IdMessageBase, MessageDefinition } from './messages'
import Joi from 'joi'
import * as Joi from 'joi'

/**
* Can only be sent after you have sent the {@link FileAnalysisRequestMessage}.
Expand Down
2 changes: 1 addition & 1 deletion src/cli/repl/server/validate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Joi from 'joi'
import * as Joi from 'joi'
import { sendMessage } from './send'
import { baseMessage, FlowrMessage, IdMessageBase, MessageDefinition } from './messages/messages'
import { FlowrErrorMessage } from './messages/error'
Expand Down

2 comments on commit 07a1487

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"artificial" Benchmark Suite

Benchmark suite Current: 07a1487 Previous: 2e17bd2 Ratio
Total per-file 2942.901727590909 ms (3593.970739056339) 3174.886931590909 ms (4133.82989376954) 0.93
Retrieve AST from R code 66.1196070909091 ms (135.99890528732774) 73.759667 ms (159.73313158842387) 0.90
Normalize R AST 96.46377136363635 ms (155.6764223691318) 97.24624554545454 ms (157.4974378518514) 0.99
Produce dataflow information 65.2993905 ms (168.3886892792559) 66.34398486363636 ms (170.59395619673015) 0.98
Total per-slice 1.8347581546119145 ms (1.254469412505978) 1.9209680083249427 ms (1.3225392322151348) 0.96
Static slicing 1.368200808050588 ms (1.157117235400419) 1.4057747356611319 ms (1.2018529713715655) 0.97
Reconstruct code 0.44716334505544825 ms (0.23393620594443693) 0.49751458799773607 ms (0.2877398660633804) 0.90
failed to reconstruct/re-parse 0 # 0 # NaN
times hit threshold 0 # 0 # NaN
reduction (characters) 0.7329390759026896 # 0.7329390759026896 # 1
reduction (normalized tokens) 0.720988345209971 # 0.720988345209971 # 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"social-science" Benchmark Suite

Benchmark suite Current: 07a1487 Previous: 2e17bd2 Ratio
Total per-file 5102.05769854 ms (5866.242964171432) 5067.11699072 ms (6013.966295548738) 1.01
Retrieve AST from R code 72.07681792 ms (65.88326405275015) 72.89874598 ms (65.47213185510104) 0.99
Normalize R AST 112.44862756 ms (68.1230588017699) 112.63807184000001 ms (69.0681140265212) 1.00
Produce dataflow information 163.37871538 ms (278.55396644677813) 163.4963136 ms (275.2982409802191) 1.00
Total per-slice 8.531401628289306 ms (14.171681830925705) 8.727472260919003 ms (14.4602468429054) 0.98
Static slicing 8.023795875197989 ms (14.04224530669901) 8.21931140277668 ms (14.341926068785162) 0.98
Reconstruct code 0.4989551531119994 ms (0.2615511593397629) 0.4984137426920286 ms (0.24500938778272444) 1.00
failed to reconstruct/re-parse 9 # 9 # 1
times hit threshold 967 # 967 # 1
reduction (characters) 0.898713819973478 # 0.898713819973478 # 1
reduction (normalized tokens) 0.8579790415512589 # 0.8579790415512589 # 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.