-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(ns-asyncapi-2-0): introduce visitor shortcut
Visitor shotcut improves performance by 8-9% during refracting phase. Closes #398
- Loading branch information
Showing
27 changed files
with
111 additions
and
66 deletions.
There are no files selected for viewing
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
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
4 changes: 1 addition & 3 deletions
4
...s/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/$RefVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const $RefVisitor = stampit(FallbackVisitor); | ||
const $RefVisitor = FallbackVisitor; | ||
|
||
export default $RefVisitor; |
4 changes: 1 addition & 3 deletions
4
...m-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/DescriptionVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const DescriptionVisitor = stampit(FallbackVisitor); | ||
const DescriptionVisitor = FallbackVisitor; | ||
|
||
export default DescriptionVisitor; |
4 changes: 1 addition & 3 deletions
4
...kages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/contact/EmailVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const EmailVisitor = stampit(FallbackVisitor); | ||
const EmailVisitor = FallbackVisitor; | ||
|
||
export default EmailVisitor; |
4 changes: 1 addition & 3 deletions
4
...ckages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/contact/NameVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const NameVisitor = stampit(FallbackVisitor); | ||
const NameVisitor = FallbackVisitor; | ||
|
||
export default NameVisitor; |
4 changes: 1 addition & 3 deletions
4
...ackages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/contact/UrlVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const UrlVisitor = stampit(FallbackVisitor); | ||
const UrlVisitor = FallbackVisitor; | ||
|
||
export default UrlVisitor; |
4 changes: 1 addition & 3 deletions
4
...es/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/info/DescriptionVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const DescriptionVisitor = stampit(FallbackVisitor); | ||
const DescriptionVisitor = FallbackVisitor; | ||
|
||
export default DescriptionVisitor; |
4 changes: 1 addition & 3 deletions
4
...apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/info/TermsOfServiceVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const TermsOfServiceVisitor = stampit(FallbackVisitor); | ||
const TermsOfServiceVisitor = FallbackVisitor; | ||
|
||
export default TermsOfServiceVisitor; |
4 changes: 1 addition & 3 deletions
4
...packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/info/TitleVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const TitleVisitor = stampit(FallbackVisitor); | ||
const TitleVisitor = FallbackVisitor; | ||
|
||
export default TitleVisitor; |
4 changes: 1 addition & 3 deletions
4
...ckages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/license/NameVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const NameVisitor = stampit(FallbackVisitor); | ||
const NameVisitor = FallbackVisitor; | ||
|
||
export default NameVisitor; |
4 changes: 1 addition & 3 deletions
4
...ackages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/license/UrlVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const UrlVisitor = stampit(FallbackVisitor); | ||
const UrlVisitor = FallbackVisitor; | ||
|
||
export default UrlVisitor; |
4 changes: 1 addition & 3 deletions
4
...idom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/parameter/DescriptionVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const DescriptionVisitor = stampit(FallbackVisitor); | ||
const DescriptionVisitor = FallbackVisitor; | ||
|
||
export default DescriptionVisitor; |
4 changes: 1 addition & 3 deletions
4
.../apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/parameter/LocationVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const LocationVisitor = stampit(FallbackVisitor); | ||
const LocationVisitor = FallbackVisitor; | ||
|
||
export default LocationVisitor; |
4 changes: 1 addition & 3 deletions
4
...ages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/$RefVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const $RefVisitor = stampit(FallbackVisitor); | ||
const $RefVisitor = FallbackVisitor; | ||
|
||
export default $RefVisitor; |
4 changes: 1 addition & 3 deletions
4
...om-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server-variable/DefaultVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const DefaultVisitor = stampit(FallbackVisitor); | ||
const DefaultVisitor = FallbackVisitor; | ||
|
||
export default DefaultVisitor; |
4 changes: 1 addition & 3 deletions
4
...s-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server-variable/DescriptionVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const DescriptionVisitor = stampit(FallbackVisitor); | ||
const DescriptionVisitor = FallbackVisitor; | ||
|
||
export default DescriptionVisitor; |
4 changes: 1 addition & 3 deletions
4
...pidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server-variable/EnumVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const EnumVisitor = stampit(FallbackVisitor); | ||
const EnumVisitor = FallbackVisitor; | ||
|
||
export default EnumVisitor; |
4 changes: 1 addition & 3 deletions
4
...m-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server-variable/ExamplesVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const ExamplesVisitor = stampit(FallbackVisitor); | ||
const ExamplesVisitor = FallbackVisitor; | ||
|
||
export default ExamplesVisitor; |
4 changes: 1 addition & 3 deletions
4
.../apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/DescriptionVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const DescriptionVisitor = stampit(FallbackVisitor); | ||
const DescriptionVisitor = FallbackVisitor; | ||
|
||
export default DescriptionVisitor; |
4 changes: 1 addition & 3 deletions
4
...dom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/ProtocolVersionVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const ProtocolVersionVisitor = stampit(FallbackVisitor); | ||
const ProtocolVersionVisitor = FallbackVisitor; | ||
|
||
export default ProtocolVersionVisitor; |
4 changes: 1 addition & 3 deletions
4
...ges/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/ProtocolVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const ProtocolVisitor = stampit(FallbackVisitor); | ||
const ProtocolVisitor = FallbackVisitor; | ||
|
||
export default ProtocolVisitor; |
4 changes: 1 addition & 3 deletions
4
...packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/UrlVisitor.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import stampit from 'stampit'; | ||
|
||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const UrlVisitor = stampit(FallbackVisitor); | ||
const UrlVisitor = FallbackVisitor; | ||
|
||
export default UrlVisitor; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"@typescript-eslint/no-var-requires": 0 | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require('@babel/register')({ extensions: ['.js', '.ts'], rootMode: 'upward' }); | ||
|
||
const Benchmark = require('benchmark'); | ||
|
||
const visitorShortcutBench = require('./visitor-shortcut'); | ||
|
||
const suite = new Benchmark.Suite(); | ||
|
||
suite | ||
.add(visitorShortcutBench) | ||
// add listeners | ||
.on('cycle', function (event) { | ||
console.info(String(event.target)); | ||
}) | ||
.on('complete', function () { | ||
console.info('\nAll benchmarks have completed'); | ||
}) | ||
// run | ||
.run(); |
41 changes: 41 additions & 0 deletions
41
apidom/packages/apidom-ns-asyncapi-2-0/test/perf/visitor-shortcut.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require('@babel/register')({ extensions: ['.js', '.ts'], rootMode: 'upward' }); | ||
|
||
const Benchmark = require('benchmark'); | ||
const { ObjectElement } = require('apidom'); | ||
|
||
const { AsyncApi2_0Element } = require('../../src'); | ||
|
||
const genericObjectElement = new ObjectElement({ | ||
asyncapi: '2.0.0', | ||
info: { | ||
title: 'Webhook Example', | ||
version: '1.0.0', | ||
description: 'description', | ||
termsOfService: 'tos', | ||
}, | ||
}); | ||
|
||
const options = { | ||
name: 'visitor-shortcut', | ||
minSamples: 700, | ||
expected: '640 ops/sec ±0.82% (780 runs sampled)', | ||
fn() { | ||
AsyncApi2_0Element.refract(genericObjectElement); | ||
}, | ||
}; | ||
|
||
module.exports = options; | ||
|
||
// we're running as a script | ||
if (module.parent === null) { | ||
const bench = new Benchmark({ | ||
...options, | ||
onComplete(event) { | ||
console.info(String(event.target)); | ||
}, | ||
onError(event) { | ||
console.error(event); | ||
}, | ||
}); | ||
bench.run(); | ||
} |
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