Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: December 3, 2024, 2:01 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PicoBlaze Simulator in JavaScript
#31
RE: PicoBlaze Simulator in JavaScript
FA - asks for help

Various knowledgeable members - offer help

FA - no that's not the answer I want

wash, rinse, repeat
[Image: MmQV79M.png]  
                                      
#32
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 4:37 pm)HappySkeptic Wrote:
(August 12, 2022 at 1:41 pm)FlatAssembler Wrote: Whence am I supposed to know all those things? I am just a third-year computer science student. And I have also been using a hell lots of things we haven't been taught at the university in my program.

A performance test is just a test program.  It could be part of a unit-test.  Just have it do something in a loop 1000 times (or some large-enough number). In Javascript

Code:
var start = performance.now();
const iterations = 1000;
for (let i = 0; i < iterations; i++) {
    // Do some testing work
}
var stop = performance.now();
console.log("Test 1 runs in " + ((stop - start)/iterations) + " ms.");

You said your program is "slow".  How do you know?  You must have expectations.  At least this way you can check if something is slow or not, and find out if you fixed it or not, by comparing these numbers.

If something is slow, do a bunch of work in the loop, and do performance timing using the F12 developer console Performance tab in Chrome.  You can start the recording from some "pause" point in your code, or you can start it with a page reload, and stop it when your code has finished.  Look for the bottom-up methods, and check for calls that use a majority of the time.

Yeah. I have done some unit tests in the AEC-to-WebAssembly compiler, but I made no unit tests in the PicoBlaze Simulator, nor would I know how exactly to do those there.
#33
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 3:16 pm)BrianSoddingBoru4 Wrote:
(August 12, 2022 at 1:41 pm)FlatAssembler Wrote: Whence am I supposed to know all those things? I am just a third-year computer science student. And I have also been using a hell lots of things we haven't been taught at the university in my program.

If you’ve been at this for three years and don’t understand performance tests, maybe you should enroll in a different CS programme.

Boru

Well, in Osijek, there are two universities teaching Computer Science, the FERIT university (the one I am attending) and the MATHOS university, and the FERIT university is considered much more prestigious.
#34
RE: PicoBlaze Simulator in JavaScript
(August 15, 2022 at 6:55 am)FlatAssembler Wrote:
(August 12, 2022 at 3:16 pm)BrianSoddingBoru4 Wrote: If you’ve been at this for three years and don’t understand performance tests, maybe you should enroll in a different CS programme.

Boru

Well, in Osijek, there are two universities teaching Computer Science, the FERIT university (the one I am attending) and the MATHOS university, and the FERIT university is considered much more prestigious.

The school is doing a dandy job of educating you if you feel the need to go to an atheist forum, as well as other social media platforms for help.
[Image: MmQV79M.png]  
                                      
#35
RE: PicoBlaze Simulator in JavaScript
(August 15, 2022 at 6:44 am)FlatAssembler Wrote: Thank you, it would be a good thing to speed up the assembler a bit. But the assembler is, at least for the test programs, already running at an acceptable speed. It is the simulator that is running way too slowly.
Well, at least this file was commented, so it's slightly more readable.  It still seems to me that so many if/else statements is likely to cause trouble-- though if you're only running programs limited to 4KB, it's hard to believe that even an inefficient algorithm would take more than a split second.

Anyway, instead of so many repeated conditionals, I'd recommend using a large "switch":
Code:
var codebyte = currentDirective & 0xff000;

switch (codebyte){
     case  0x00000:
        //Call a Register load from register function here.
     break;
      case 0x01000:
         //Call a Register load from value function here.
      break;
}

It's (much) better to generate a lookup table on compile than to keep constantly doing new comparisons.  (I'm not so sure how much this will actually affect processing a small amount of data though).
#36
RE: PicoBlaze Simulator in JavaScript
(August 15, 2022 at 6:57 am)arewethereyet Wrote:
(August 15, 2022 at 6:55 am)FlatAssembler Wrote: Well, in Osijek, there are two universities teaching Computer Science, the FERIT university (the one I am attending) and the MATHOS university, and the FERIT university is considered much more prestigious.

The school is doing a dandy job of educating you if you feel the need to go to an atheist forum, as well as other social media platforms for help.
What does "dandy" mean?
#37
RE: PicoBlaze Simulator in JavaScript
(August 15, 2022 at 9:35 am)bennyboy Wrote:
(August 15, 2022 at 6:44 am)FlatAssembler Wrote: Thank you, it would be a good thing to speed up the assembler a bit. But the assembler is, at least for the test programs, already running at an acceptable speed. It is the simulator that is running way too slowly.
Well, at least this file was commented, so it's slightly more readable.  It still seems to me that so many if/else statements is likely to cause trouble-- though if you're only running programs limited to 4KB, it's hard to believe that even an inefficient algorithm would take more than a split second.

Anyway, instead of so many repeated conditionals, I'd recommend using a large "switch":
Code:
var codebyte = currentDirective & 0xff000;

switch (codebyte){
     case  0x00000:
        //Call a Register load from register function here.
     break;
      case 0x01000:
         //Call a Register load from value function here.
      break;
}

It's (much) better to generate a lookup table on compile than to keep constantly doing new comparisons.  (I'm not so sure how much this will actually affect processing a small amount of data though).

I have always thought switch-case and large else-if statements compiled into the same assembly code.
#38
RE: PicoBlaze Simulator in JavaScript
(August 16, 2022 at 12:38 pm)FlatAssembler Wrote: I have always thought switch-case and large else-if statements compiled into the same assembly code.

It depends on the language and how many items are in the switch statement.

Best case, the switch turns into a lookup table or map of jump instructions.  Worst case they are the same.  That makes switch the smart choice, as well as making the code more readable.
#39
RE: PicoBlaze Simulator in JavaScript
(August 16, 2022 at 12:38 pm)FlatAssembler Wrote: I have always thought switch-case and large else-if statements compiled into the same assembly code.
That doesn't make sense.  If you have a series of say 100 if/else statements, it is going to have to evaluate those one-by-one as part of the control flow of the app.  But a switch statement can be evaluated as a single flow item. Look at your code-- how will you ever arrive at those items near the end of your long if/else chains? There's no way but for the CPU to go through all of those many evalutions one-by-one.

Now, I'm not an expert in computer languages. I can imagine that a very clever compiler will realize that all your conditional statements are being performed on the same object, and just generate a lookup table. But I'd be pretty surprised if that were the case with JavaScript running in a browser.

And EVEN IF they compiled the same (which I really do doubt), the appearance of code matters, too. A switch is easier to read.
#40
RE: PicoBlaze Simulator in JavaScript
(November 14, 2020 at 3:35 pm)FlatAssembler Wrote: Can anybody here diagnose why the layout breaks in Firefox for Android when in the Landscape mode?

Why are you always asking us to do your homework for you?
Nay_Sayer: “Nothing is impossible if you dream big enough, or in this case, nothing is impossible if you use a barrel of KY Jelly and a miniature horse.”

Wiser words were never spoken. 



Possibly Related Threads...
Thread Author Replies Views Last Post
  A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript FlatAssembler 81 9434 December 19, 2023 at 4:46 pm
Last Post: BrianSoddingBoru4
  Reformatting tools for JavaScript FlatAssembler 0 450 June 14, 2020 at 10:13 am
Last Post: FlatAssembler
  Anatomy of religion in RELIGION SIMULATOR game gravitysoftware 12 3390 February 8, 2015 at 12:52 pm
Last Post: c172
  Analysis of a Facebook social engineering/Javascript "hack" Autumnlicious 4 3496 March 2, 2011 at 9:29 am
Last Post: fr0d0



Users browsing this thread: 2 Guest(s)