Jump to content

G1K777

Member
  • Posts

    100
  • Joined

  • Last visited

Everything posted by G1K777

  1. Sorry for "spamming" but I can't add code when editing posts. Here is also another test. It loops out every value into a div. Not everything at once, but each single value from the array at time. Loop - prototype -: 54ms script.js:33:1 Loop - for -: 84ms script.js:50:1 Array length 1000 Why this test? Imagine looping a huge table with "Game Items" "Articles" etc. The other thing is also that the for of loop has error checking, my loop is just = speed. // Set variables const demo = document.getElementById('demo'), add = (x)=>demo.innerHTML+=x; let arr = [], o = '', loop; // Generate the test array with random strings for (let i = 0; i < 1000; i++) { arr[i] = Math.random().toString(36).substring(2, 3 + Math.floor(Math.random() * 9)); } Array.prototype.loop = function(func) { let l = this.length, i = 0; for (; i < l;) { func(this[i]); i++; } } // Prototype o = ''; console.time(loop = 'Loop - prototype -') arr.loop(add); demo.innerHTML = ''; o = ''; arr.loop(add); demo.innerHTML = ''; o = ''; arr.loop(add); console.timeEnd(loop); // for loop console.time(loop = 'Loop - for -') for (let i of arr) { add(i); } demo.innerHTML = ''; o = ''; for (let i of arr) { add(i); } demo.innerHTML = ''; o = ''; for (let i of arr) { add(i); } console.timeEnd(loop); // console.log(o) console.log('Array length', arr.length);
  2. I improved the code a bit and now it's always faster than the for loop by 2x-3x. Loop - prototype -: 5ms script.js:30:1 Loop - for -: 12ms script.js:45:1 Array length 100000 minimalizing it with a compressor reduces the avg time by 1ms. So it's 4ms for the prototype and 1-2ms less for the for in loop. (function() { // Set variables const add = (x)=>o+=x; let arr = [], o = '', loop; // Generate the test array with random strings for (let i = 0; i < 100000; i++) { arr[i] = Math.random().toString(36).substring(2, 3 + Math.floor(Math.random() * 9)); } Array.prototype.loop = function(func) { let l = this.length, i = 0; for (; i < l;) { func(this[i]); i++; } } // Prototype o = ''; console.time(loop = 'Loop - prototype -') arr.loop(add); o = ''; arr.loop(add); o = ''; arr.loop(add); console.timeEnd(loop); // for loop console.time(loop = 'Loop - for -') for (let i of arr) { add(i); } o = ''; for (let i of arr) { add(i); } o = ''; for (let i of arr) { add(i); } console.timeEnd(loop); // console.log(o) console.log('Array length', arr.length); } )(); deleting the anon si function at the beginning, improves the for in loop a bit, makes it more constant. So it doesn'g go: Loop - prototype -: 5ms script.js:30:1 Loop - for -: 37ms script.js:45:1 Array length 100000
  3. But how? When I use the forEach loop and look at the time in the consoles performance tab (Firefox). It says 1ms vs my prototypes 1.4ms. But in your example it looks like my code is faster..
  4. @gator81 To know more, you need to research more. There are more forums, communities than LTT. I'm researching first on my own... then after 30min I decide, do I need to fix/know this right now? If yes I visit a forum and ask it there, if not, I continue my research. Researching is better than asking one question. Why? When you research, you learn WAYYY more things that way, you find sometimes other cool topics, other information. I'm 100% sure you can find those things online. One annoying thing is, that mainboard manufacturers don't use the same shortcuts. For example LLC has far I've seen always the same name in mainboards LLC (Load Line Calibration). But VCCIO is also known as VTT and QPI.
  5. Okay got it, thanks guys Array.prototype.loop = function(func) { let l = this.length; for( let i = 0; i < l; i++ ){ func(this); } } arr.loop(function(x) { console.log(x); }); (( Can't post it as code for some reason )) I wonder why it's so slow. http://jsben.ch/3H35T // EDIT Tested it in Firefox Nightly and the results are different. The "for of" loop needs ~3ms to loop about 6.7k values. My prototype function needs about 0.11ms. That's what my browser says. Did 6 tests and it's always the same. test.js
  6. Not like this. There are exmaples above what I'm looking for.
  7. I killed 2 Mainboards and 1 RAM DIMM, the "big static discharge" is wrong. Depending on the part you touch it can be a tiny discharge to kill a sensitive component. Don't build anything on a carpet. Discharge yourself by touching a plugged in powersupply(doesn't need to be turned on). You can also discharge yourself by touching a heater(on a wall). When you build, try to touch only plastic components, coolers and heatsinks.
  8. Hi, I want to use a custom function inside a function. Not something like this. function myFunction(){ function secondFunction(x){ console.log(x) } } I want to pass a custom function into another function. Array.prototype.loop = function(f){ for(i = 0; i < this.length; i++){ return this[i]; } } function test(x){ // this is just a example. console.log(x); } arr.loop(test()); Should work similar to "forEach" where you pass a function inside. myArray.forEach(function(x) { console.log(x); });
  9. Hello, I was using Spyder5 Elite before on a single monitor setup and never had any issue with it. Now I have two monitors and it has some issues. BenQ XL2540 (1080p 240hz TN) Asus PB278QR (1440p 60hz IPS) It worked for the first 2 days and now it won't load any profiles, colors etc. I can tell that the calibration isn't enabled because when I disable it from the icon tray it looks exactly the same. I went also to: Settings > Display > Advanced disply settings > Display adaptor properties for Display 1 > Colour Management > and the ICC Profile is set to the current profile "BenQ XL2540 28.12.18.icm" and the "Use my settings for this device" is also checked. I'm getting slowly pissed by all these companies who can't make just simple programs work, just work. I'm spending more time fixing stuff on windows10 than using it or playing games.
  10. Hello, this question might seem bit stupid but I'm dead serious with it. To write a simple "Hello World!" in Go is simpler than doing this in NodeJS (Because NodeJS has a trash setup). package main import "fmt" func main(){ fmt.Println("Hello World") } Very simple right? Each Youtube video about Golang I've seen kind helps but not really. All you hear "do this, this is for that.." but not in the Docs nor in any Youtube video have they explained the basics. I mean how do you write variables in other languages? // JS var varName = 5; let varName = 5; const varName = 5; // or var varName1 = 5, varName2 = 6, varName3 = 7; //etc. Works same with const and let. With PHP it's also easy, $variableName and it's done. But in Golang I saw no one explaining this: something := 5 // <-- talking about this. var otherSomething int = 5 Luck that there is something like w3schools, MDN that makes everything really easy but where the heck do I learn the fundamentals of Golang? All I want to do, is getting a webhost working on my PC. That's all. The issue is, my browser (chrome) is loading the index.html but how do I load the CSS and JS? I'm siting since 35-40h (in total, sleeping and breakes not included) googling Golang, the whole time. I'm kinda pissed how you can tell, who wouldn't be? It took me 1 day to run NodeJS without using express and make my website run on it. With Golang I'm sitting here and i know nothing, the docs don't give you a starting point at all. They teach me how to make a gowiki where the content is loaded from txt files ? Like you seruous, txt files? This is what i have now and don't ask me how it works. package main import ( "io/ioutil" "net/http" ) type MyHandler struct { http.Handler } func (this *MyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { path := "public/index.html" // + req.URL.Path data, err := ioutil.ReadFile(string(path)) if err == nil { w.Write(data) } else { w.WriteHeader(404) w.Write([]byte("404 - " + http.StatusText(404))) } } func main() { http.Handle("/", new(MyHandler)) http.ListenAndServe(":3000", nil) } I never coded anything in Python, Delphi, any C language.
  11. G1K777

    PC for VR

    It sounds like you're using one GPU for SS and the other for rendering ?
  12. G1K777

    PC for VR

    I guess i will go with 9700K + 2080 ti then. 2080ti is still kinda garbage.You pay 400Euros for a feature that you won't use.
  13. Hello, i see that here is no category for PC builds. I want to build PC for VR and not sure if i want to go with single GPU or SLI. If i go with SLI i prob need to use the 2066 CPUs because of the PCIe lanes right ? With single GPU i would take prob 9700K + RTX 2080ti. I would use 2x 1080ti for the SLI config but which CPU 2066 ?
  14. If you make a console that handles a game like Crysis 3 at 4K with 90FPS in VR... PCs might die... it doesn't look like consoles will become that fast. I wish this would happen, I'm sick of building PCs and building and building. Buy, power on... and play at Ultra settings. I wish they would make computers like consoles that would be even cheaper.
  15. Plan change, i found a easier way But still have problems with it ughhh... I created few pages in the "page" object. So the page object has multiple "test" pages. content.loadPage(); //is a method that renders whe whole page from the page object. content.loadPage(pages.article); //renders/opens the article. (works like a charm). I want to load pages on hashchange, this isn't also a problem to get the hash: loadPage(){ let hash = location.hash.replace('#',''); id('col_content').innerHTML = this.get(pages.article); } The issue is, when i get the hash, it's a string. So how to make something like: "pages.hash". When i do this it's page.'myhash' as a string. How do i get the property ? WAIT! I just remembered that there are two ways ! pages.article //Gets the article property from pages. pages['article'] //Does the same and it uses a STRING! :D Sometimes I'm just mad at myself, it took me 1-2h to realize that, i've tested each possible position of that function OMG, variables, even set a global variable to make it work! after 2h. Feels better than eating icecream and not getting fat.
  16. The function above adds a custom function to the addEventListener and i created another function: function getValue(){ console.log(this); } $('#nav_a a','click',getValue); When i click on the link it outputs the anchor element, so far everything is okay. My problem is when i try to get the attribute of "this" or "this.getValue", "this.value" everything results with undefined.
  17. I did this here: function $(e,m,func){ document.querySelectorAll(e).forEach(function(x){ x.addEventListener(m,func); }); } Is yours faster?
  18. Hello,how can i get the clicked button with Javascript? I know how to do it with ID. document.getElementById('myElement').addEventListener('click', function(){ //do something } But how can i do this when i have a website with multiple "Save" buttons that have a class of "save" ? How do i get the right button? So only that one thing will save? For forms I'm using submit. I'm not using Jquery, but with Jquery i simply do $('.save') and i get all the elements with a class "save". Does Jquery just loop .addEventListener() on all the elements or how does it work? I have this so far: (not rly far but... meh) function cl(e){ document.querySelectorAll(e).forEach(function(x){ debug(x); }); } It outputs all the elements into the console, should i do the same but with .addEventListener?
  19. How can i prevent all forms from default submission? I want to use AJAX on all forms. I was trying and trying things but Javascript doesn't look like they like to make coding easier... Why i can't just do the following? (doesn't work, it still submits the form.) let form = document.getElementsByTagName("form"); form.addEventListener("submit", function(event){ event.preventDefault() });
  20. Thank you, you know how it is.. when you code from 7pm till 7am and start making simple mistakes that you don't see.
  21. Hello, i want to create a login system. My code isn't adding anything into the Table, it also doesn't throw any errors. try{ conn = await conn_sql.getConnection(); await conn.query(`INSERNT INTO user (username,password) VALUES ('${data.username}','${data.password}')`); }catch(err){ throw err; }finally{ if(conn) return conn.end(); }
  22. Still not better than the ones that I've found, thank you for the good will.
  23. Sorry but I'm not happy with any of those laptops. The displys are tiny, some of them have a lower resolution than 1080p. I found also one: https://geizhals.de/hp-17-ca0013ng-silber-4au02ea-abd-a1836181.html?hloc=at&amp;hloc=de
  24. https://geizhals.de/ No preferred weight. Weight shouldn't be a concern for me, it's not for school :)
×