Jamie Balfour BSc

Welcome to my personal website!

Technology enthusiast

I am very interested in technology, particularly relating to computer science. I am most interested in web design and development.

My main hobby is programming. One of my most well known products from this is ZPE. I also am the sole creator of BalfBlog, BalfBar and BalfSlider.

A little bit about me

In 1997, when I was six years of age, I got my very first computer. I was always very interested in the ins and outs of it and dismantled it to see how it worked.

Years later, in 2016 I received my BSc (with honours) in Computer Science, obtaining a First class degree.

I'd like to welcome you to my website and hope you enjoy using it as much as I have enjoyed building it!

Google Plus
Ghost
Me
Jamie Balfour BSc
Full stack developer

Improving the speed and efficiency of a program

31 May 2016 at 09:16
In this post I talk about a newly found way of improving speed of a program

Over the last few years, I've done a lot of work on building my own programming language and platform known collectively as Zengin. 

Perhaps the most important lesson I have learned from this is how to make a program more efficient. I focus a lot on shifting things from the interpreter side/runtime side to the compile time side in ZPE, and that has been a major focus of the latest version. However, there are somethings that I cannot do very easily.

I recently started to think about making one of my programs more efficient and started thinking how this would work in ZPE. Let's take a look at some code:

ZenLang
$list = range(1, 5000)
//For x is less than the length of the list (i.e. 5000), increment by 1 
for ($x = 0, $x < list_get_length($list), 1)
    print($i)
end for

Notice how we check the size of the list at the top of the for? This means each iteration will need to call that function to find the size of the array. If a variable had been defined prior to the for loop and contained the length of the list, one could simply reference the variable, which in turn would be much faster than constantly asking the system to find the length of a 5,000 element array. Here is a sample of this in action.

ZenLang
$list = range(1, 5000)
$len = list_get_length($list)
//For x is less than the length of the list (i.e. 5000), increment by 1 
for ($x = 0, $x < $len, 1)
    print($i)
end for

Times were measured using the Unix time command and were as follows:

For the first test:

real 0m1.821s

user 0m2.862s

sys 0m0.363s

And for the second test:

real 0m0.437s

user 0m1.051s

sys 0m0.099s

This is the first tip I have for you. This tip will also work in other languages such as JavaScript or Java or whatever. 

Difference in speed

Site accessibility

A lot of the original functionalities that once existed here have been removed.

This page was generated in 0.27 seconds using 2097152 bytes. Slow? Let me know.

To use project mode, the window must be greater than 920 pixels in width.
Click here to disable Project Mode.
This site uses cookies to deliver its services, to personalise ads, to store preferences and to analyse traffic. Information about your use of this site is shared with other companies. By using this site, you agree to its use of cookies.
Contact me
Contact Jamie Balfour

Get in touch with me via this form.