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, 1:50 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PicoBlaze Simulator in JavaScript
#21
RE: PicoBlaze Simulator in JavaScript
@bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.
#22
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 7:26 am)FlatAssembler Wrote: @bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.

Maybe you should either take some remedial courses or hire yourself a tutor.

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
#23
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 7:26 am)FlatAssembler Wrote: @bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.

No-one is going to help you on such a generic question.  First, write a series of performance tests with timings.  Then, use the a performance tool on whatever Javascript system you are on (the one in Chrome are good).  Look for hot spots in the bottom-up profiling.

When coding for performance, I always have an idea of the performance I'm expecting.  I break down the pieces and check the speed of each.  If you aren't testing with actual numbers, you have nothing to go by.
#24
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 9:24 am)HappySkeptic Wrote:
(August 12, 2022 at 7:26 am)FlatAssembler Wrote: @bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.

No-one is going to help you on such a generic question.  First, write a series of performance tests with timings.  Then, use the a performance tool on whatever Javascript system you are on (the one in Chrome are good).  Look for hot spots in the bottom-up profiling.

When coding for performance, I always have an idea of the performance I'm expecting.  I break down the pieces and check the speed of each.  If you aren't testing with actual numbers, you have nothing to go by.

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.
#25
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 7:28 am)BrianSoddingBoru4 Wrote:
(August 12, 2022 at 7:26 am)FlatAssembler Wrote: @bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.

Maybe you should either take some remedial courses or hire yourself a tutor.

Boru

What are "remedial courses"? What's a "tutor"?
#26
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 1:43 pm)FlatAssembler Wrote:
(August 12, 2022 at 7:28 am)BrianSoddingBoru4 Wrote: Maybe you should either take some remedial courses or hire yourself a tutor.

Boru

What are "remedial courses"? What's a "tutor"?

Remedial courses are ones you take to learn (or re-learn) the basics. A tutor is a private teacher.

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
#27
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 1:41 pm)FlatAssembler Wrote:
(August 12, 2022 at 9:24 am)HappySkeptic Wrote: No-one is going to help you on such a generic question.  First, write a series of performance tests with timings.  Then, use the a performance tool on whatever Javascript system you are on (the one in Chrome are good).  Look for hot spots in the bottom-up profiling.

When coding for performance, I always have an idea of the performance I'm expecting.  I break down the pieces and check the speed of each.  If you aren't testing with actual numbers, you have nothing to go by.

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
‘I can’t be having with this.’ - Esmeralda Weatherwax
#28
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 1:41 pm)FlatAssembler Wrote:
(August 12, 2022 at 9:24 am)HappySkeptic Wrote: No-one is going to help you on such a generic question.  First, write a series of performance tests with timings.  Then, use the a performance tool on whatever Javascript system you are on (the one in Chrome are good).  Look for hot spots in the bottom-up profiling.

When coding for performance, I always have an idea of the performance I'm expecting.  I break down the pieces and check the speed of each.  If you aren't testing with actual numbers, you have nothing to go by.

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.
#29
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 7:26 am)FlatAssembler Wrote: @bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.

Yes, I think so.  This is not really a web issue, though-- it would be the same in any language running under any framework.

In `assembler.js`, your main loop, "assemble", has 2 problems:

1)  From an engineering perspective, it is absolutely unreadable.  I've never seen that many if/else statements on a single page in my life.  Let's say you have one or two mistakes in all those statements-- hell if you'll find ANYONE willing to go through that pile of spaghetti to find them.

2)  From an efficiency perspective, you seem to be doing dozens (hundreds?) of conditional operations on each node.  You need to use switch statements or some other type of logic to reduce unnecessary checks.

Also: you have this
Code:
if (node.children[0].getRegisterNumber(context.namedRegisters) === "none") DoErrorStuff{};
multiple times.  Why not just assign that equation to a bool and use that?  (Again, I don't really use JavaScript, so you can fix the syntax if it's not right)
Code:
var IsRegister = node.children[0].getRegisterNumber(context.namedRegisters) !== "none"
. . .

if (!IsRegister) DoErrorStuff{}; // Use this the next 1000 times you need the same exact check
Then your poor CPU doesn't have to keep running the same eqaulity check 1000 times.
#30
RE: PicoBlaze Simulator in JavaScript
(August 12, 2022 at 6:34 pm)bennyboy Wrote:
(August 12, 2022 at 7:26 am)FlatAssembler Wrote: @bennyboy , you say you are an experienced web developer. Could you please look into my PicoBlaze Simulator in JavaScript and tell me how I could speed it up? I cannot diagnose why it is so slow.

Yes, I think so.  This is not really a web issue, though-- it would be the same in any language running under any framework.

In `assembler.js`, your main loop, "assemble", has 2 problems:

1)  From an engineering perspective, it is absolutely unreadable.  I've never seen that many if/else statements on a single page in my life.  Let's say you have one or two mistakes in all those statements-- hell if you'll find ANYONE willing to go through that pile of spaghetti to find them.

2)  From an efficiency perspective, you seem to be doing dozens (hundreds?) of conditional operations on each node.  You need to use switch statements or some other type of logic to reduce unnecessary checks.

Also: you have this
Code:
if (node.children[0].getRegisterNumber(context.namedRegisters) === "none") DoErrorStuff{};
multiple times.  Why not just assign that equation to a bool and use that?  (Again, I don't really use JavaScript, so you can fix the syntax if it's not right)
Code:
var IsRegister = node.children[0].getRegisterNumber(context.namedRegisters) !== "none"
. . .

if (!IsRegister) DoErrorStuff{}; // Use this the next 1000 times you need the same exact check
Then your poor CPU doesn't have to keep running the same eqaulity check 1000 times.

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.



Possibly Related Threads...
Thread Author Replies Views Last Post
  A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript FlatAssembler 81 9431 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)