Comments (3)
I can see only 1 potential benefit which might be worth: performance.
However, is .toString(36)
working on all browsers?
Have you benchmarked that something like return Math.random().toString(36).substr(2,16);
is actually faster than the loop?
from autobahn-js.
Number.toString(36)
has been supported since the early days so we should have it in IE.
I ran some jsPerf tests and the shorter code came out about 10%-20% faster: http://jsperf.com/randomstring-tostring-and-for
The other advantage here is a less complex code base (even if it's marginally so). If the .
artifact doesn't bother you, it also improves the speed.
from autobahn-js.
First off, the jsPerf site is really cool! Didn't know that.
Now, I also did some tests: http://jsperf.com/generate-random-id/2
Results:
- with Firefox the modified ID function is slower than the current one
- all other browsers tested were faster
- the variant with most consistent performance across browsers is variant 4
In any case, we are talking about 300k ops/s even for the slowest (Opera with existing function). In practice, it won't matter at all.
I don't bother about code .. it's trivial in any of the variants.
If you still care, send me a pull with a new function ab._newidFast
(leaving the old function there/untouched) with implementation return Math.random().toString(36);
and change the single line where it is called to call that new function. Add a link to above perf test in a code comment. I'd merge that ..
Thanks!
from autobahn-js.
Related Issues (20)
- Subprotocol error when creating connection with [email protected] HOT 9
- Connections failed on SSL HOT 2
- Is there any way to send a blob? HOT 1
- autobahn.Error should contain the "details" parameter HOT 1
- Add a HarmonyOS-supported polyfill
- uncaught referenceerror: cr is not defined at <anonymous>:2:3
- Implement Payload Passthru Mode HOT 1
- Release 22.10.1 HOT 3
- autobahn js => es6 ? HOT 3
- cbor: problem sending payload larger than 16kb HOT 2
- Release v22.11.1
- Support latest ws 8.x
- Wrapping/unwrapping invocation results HOT 7
- How disconnect or close connection? HOT 1
- Subscribe does not fire when something is published
- Session detached after new session attached, resulting in `wamp.error.procedure_already_exists` HOT 5
- can you make a rpc call outside of onopen ? so you dont have to make parrallel connections everytime you want to make a call ?
- Support call cancelling via AbortController
- WebSocket connection to 'wss://site.com/socket/' failed
- Correct copyright holder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autobahn-js.