-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(encoder): fixed the debuff of encoder
- Loading branch information
Showing
42 changed files
with
1,034 additions
and
205 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/test/ | ||
/dist/ | ||
/benchmarks/ | ||
/*.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# Changes Logs | ||
|
||
## v0.2.0 | ||
|
||
- refactor(global): Improved the experience. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright 2020 Angus.Fenying <fenying@litert.org> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as $Televoke from '../../lib'; | ||
|
||
export const BENCHMARK_SERVER_HOST = '127.0.0.1'; | ||
export const BENCHMARK_SERVER_PORT = 9988; | ||
|
||
export interface IGreetArguments { | ||
|
||
name: string; | ||
} | ||
|
||
export interface IGa extends $Televoke.IServiceAPIs { | ||
|
||
hi(data: IGreetArguments): string; | ||
|
||
Hello(data: IGreetArguments): string; | ||
|
||
TestError(data: IGreetArguments): string; | ||
} |
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,50 @@ | ||
/** | ||
* Copyright 2020 Angus.Fenying <fenying@litert.org> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as $Televoke from '../../lib'; | ||
import { IGa, BENCHMARK_SERVER_PORT, BENCHMARK_SERVER_HOST } from './API'; | ||
|
||
(async () => { | ||
|
||
const client = $Televoke.createHttpClient<IGa>(BENCHMARK_SERVER_HOST, BENCHMARK_SERVER_PORT, Math.random); | ||
|
||
await client.connect(); | ||
|
||
console.time('TCP Invoke Concurrent'); | ||
await Promise.all(Array(10000).fill(0).map(() => client.invoke('hi', {name: 'Angus'}))); | ||
console.timeEnd('TCP Invoke Concurrent'); | ||
|
||
console.time('TCP Invoke Sequence'); | ||
for (let i = 0; i < 10000; i++) { | ||
|
||
await client.invoke('hi', {name: 'Angus'}); | ||
} | ||
console.timeEnd('TCP Invoke Sequence'); | ||
|
||
console.time('TCP Call Concurrent'); | ||
await Promise.all(Array(10000).fill(0).map(() => client.call('hi', {name: 'Angus'}))); | ||
console.timeEnd('TCP Call Concurrent'); | ||
|
||
console.time('TCP Call Sequence'); | ||
for (let i = 0; i < 10000; i++) { | ||
|
||
await client.call('hi', {name: 'Angus'}); | ||
} | ||
console.timeEnd('TCP Call Sequence'); | ||
|
||
await client.close(); | ||
|
||
})().catch(console.error); |
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,48 @@ | ||
/** | ||
* Copyright 2020 Angus.Fenying <fenying@litert.org> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as $Televoke from '../../lib'; | ||
import { IGa, BENCHMARK_SERVER_PORT, BENCHMARK_SERVER_HOST } from './API'; | ||
|
||
(async () => { | ||
|
||
const router = $Televoke.createSimpleRouter(); | ||
|
||
router.add<IGa['hi']>('hi', async function(data) { | ||
|
||
return `Hi, ${data.name}`; | ||
}); | ||
|
||
router.register<IGa['Hello']>('Hello', async function(_) { | ||
|
||
return `Hello, ${_.args[0].name}`; | ||
}); | ||
|
||
router.add<IGa['TestError']>('TestError', async function(data) { | ||
|
||
throw `Hello, ${data.name}`; | ||
}); | ||
|
||
const server = $Televoke.createServer(); | ||
|
||
server.setRouter(router); | ||
server.on('error', console.error); | ||
server.on('handler_error', console.error); | ||
server.addGateway('tcp', $Televoke.createHttpGateway(BENCHMARK_SERVER_HOST, BENCHMARK_SERVER_PORT)); | ||
|
||
await server.start(); | ||
|
||
})().catch(console.error); |
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,34 @@ | ||
/** | ||
* Copyright 2020 Angus.Fenying <fenying@litert.org> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as $Televoke from '../../lib'; | ||
|
||
export const BENCHMARK_SERVER_HOST = '127.0.0.1'; | ||
export const BENCHMARK_SERVER_PORT = 9988; | ||
|
||
export interface IGreetArguments { | ||
|
||
name: string; | ||
} | ||
|
||
export interface IGa extends $Televoke.IServiceAPIs { | ||
|
||
hi(data: IGreetArguments): string; | ||
|
||
Hello(data: IGreetArguments): string; | ||
|
||
TestError(data: IGreetArguments): string; | ||
} |
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,65 @@ | ||
/** | ||
* Copyright 2020 Angus.Fenying <fenying@litert.org> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as $Televoke from '../../lib'; | ||
import { IGa, BENCHMARK_SERVER_PORT, BENCHMARK_SERVER_HOST } from './API'; | ||
|
||
const ridGenerator = (function() { | ||
|
||
let i = 0; | ||
return () => i++; | ||
})(); | ||
|
||
const CONCURRENCY = 10000; | ||
|
||
(async () => { | ||
|
||
const client = $Televoke.createTCPClient<IGa>(BENCHMARK_SERVER_HOST, BENCHMARK_SERVER_PORT, ridGenerator); | ||
|
||
await client.connect(); | ||
|
||
await Promise.all(Array(CONCURRENCY).fill(0).map(() => client.invoke('hi', {name: 'Angus'}))); | ||
|
||
for (let i = 0; i < CONCURRENCY; i++) { | ||
|
||
await client.invoke('hi', {name: 'Angus'}); | ||
} | ||
|
||
console.time(`TCP ${CONCURRENCY} Invokes Concurrent`); | ||
await Promise.all(Array(CONCURRENCY).fill(0).map(() => client.invoke('hi', {name: 'Angus'}))); | ||
console.timeEnd(`TCP ${CONCURRENCY} Invokes Concurrent`); | ||
|
||
console.time(`TCP ${CONCURRENCY} Invokes Sequence`); | ||
for (let i = 0; i < CONCURRENCY; i++) { | ||
|
||
await client.invoke('hi', {name: 'Angus'}); | ||
} | ||
console.timeEnd(`TCP ${CONCURRENCY} Invokes Sequence`); | ||
|
||
console.time(`TCP ${CONCURRENCY} Calls Concurrent`); | ||
await Promise.all(Array(CONCURRENCY).fill(0).map(() => client.call('hi', {name: 'Angus'}))); | ||
console.timeEnd(`TCP ${CONCURRENCY} Calls Concurrent`); | ||
|
||
console.time(`TCP ${CONCURRENCY} Calls Sequence`); | ||
for (let i = 0; i < CONCURRENCY; i++) { | ||
|
||
await client.call('hi', {name: 'Angus'}); | ||
} | ||
console.timeEnd(`TCP ${CONCURRENCY} Calls Sequence`); | ||
|
||
await client.close(); | ||
|
||
})().catch(console.error); |
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,48 @@ | ||
/** | ||
* Copyright 2020 Angus.Fenying <fenying@litert.org> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as $Televoke from '../../lib'; | ||
import { IGa, BENCHMARK_SERVER_PORT, BENCHMARK_SERVER_HOST } from './API'; | ||
|
||
(async () => { | ||
|
||
const router = $Televoke.createSimpleRouter(); | ||
|
||
router.add<IGa['hi']>('hi', async function(data) { | ||
|
||
return `Hi, ${data.name}`; | ||
}); | ||
|
||
router.register<IGa['Hello']>('Hello', async function(_) { | ||
|
||
return `Hello, ${_.args[0].name}`; | ||
}); | ||
|
||
router.add<IGa['TestError']>('TestError', async function(data) { | ||
|
||
throw `Hello, ${data.name}`; | ||
}); | ||
|
||
const server = $Televoke.createServer(); | ||
|
||
server.setRouter(router); | ||
server.on('error', console.error); | ||
server.on('handler_error', console.error); | ||
server.addGateway('tcp', $Televoke.createTCPGateway(BENCHMARK_SERVER_HOST, BENCHMARK_SERVER_PORT)); | ||
|
||
await server.start(); | ||
|
||
})().catch(console.error); |
Oops, something went wrong.