Filed Under: Development, Tech Insight by midas — Comments Off on Optimizing Source Code with AI
January 10, 2024
Often in the release notes for our MIDAS room scheduling software, you may see the entry “Code Optimization”.
What is “Code Optimization”?
Code optimization is the process of refining our software’s source code to make it execute more efficiently, consume fewer resources, or improve its overall performance. It involves strategically modifying source code whilst at the same time ensuring the new code still produces the correct results.
Key goals of source code optimization:
Enhanced speed: Executing tasks more quickly
Reduced resource consumption: Using less memory, CPU cycles, or power
We performed this AI code optimization as an experiment to see whether AI could potentially be used to aid our development processes in the future.
We chose a small “subroutine” from our software and asked an AI if it could optimize it for us.
A “subroutine” is essentially a small block of code which can be re-used and “called” repeatedly during a program’s execution.
The subroutine within the MIDAS software code that we asked an AI if it could optimize for us was basically a function which converts dates to “epoch” time.
Epoch time is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).
How did the AI do?
Our original subroutine was 15 lines of code long. Using AI to optimize code, reduced this subroutine down to just 9 lines of code.
However, the initial source code that the AI generated for us did not just work “out of the box”. In fact, it didn’t work at all!
But using this AI generated code as a “template”, our team was able to modify the generated code so that it worked and produced the correct results.
Our team then extensively tested the new subroutine to ensure that it consistently produced the same expected output as the original subroutine.
Once we had a working subroutine that we were confident in, the next step was to “benchmark” the new routine against the old one. After all, there would be no point in using the new routine if there were no performance gains to be had, or indeed if the new code performed worse than the original.
To test this, we ran each subroutine 10,000,000 (10 million times), and analyzed the results:
To explain the above results, over 10 million iterations of each subroutine, the new AI optimized subroutine was more efficient. It ran (executed) quicker, and consumed less processing (CPU) power to achieve the same results as the original subroutine.
On our test server, the optimized subroutine was able to run 369,085 times in the space of one second, compared with 330,229 times in the space of a second for the original subroutine.
Ok, so the original subroutine was pretty quick and efficient to begin with – but with the assistance of AI, we were able to improve its efficiency by almost 12%.
Where do we go from here?
Firstly, don’t worry, Artificial Intelligence is not about to take over the development of our MIDAS software!
MIDAS has been – and will remain – coded, developed, and maintained by human programmers.
But our experiment – on a very small part of our code – has demonstrated that AI tools may be able to assist our human developers to write ever more efficient source code.
The result of such carefully applied optimizations is that our software can potentially run faster, use resources more efficiently, and provide a better overall user experience.
It’s an exciting time in the world of Artificial Intelligence (AI), especially when it comes to AI powered interactive chat “bots”.
You may well have heard about “ChatGPT“, which is funded by Microsoft, and who are now starting to integrate its capabilities into the Bing search engine.
So for a bit of fun, we decided to put both of these leading AI chat bots to the test. We asked them both a very simple question to see if they knew…
“What is MIDAS room booking software?”
Here’s what ChatGPT has to say…
MIDAS (which stands for Meeting Room Scheduling) is a web-based software application designed to help organizations manage their room booking and scheduling needs. The software allows users to book meeting rooms, conference rooms, and other facilities quickly and easily, and provides a range of tools to help manage the booking process efficiently.
MIDAS allows users to set up and manage multiple rooms, view real-time availability, and make bookings directly through the software. It also includes features such as email notifications, automated invoicing, and reporting tools to help track usage and optimize room allocation.
MIDAS is a popular choice for businesses, schools, and other organizations that need to manage their room scheduling needs efficiently. It is easy to use, flexible, and customizable, making it suitable for a wide range of applications.
– ChatGPT
Here’s what Google’s Bard has to say…
MIDAS is a cloud-based room booking software that helps businesses and organizations of all sizes manage their meeting and event spaces. With MIDAS, users can easily book rooms, track room availability, and manage room reservations. MIDAS also offers a variety of features that can help businesses save time and money, such as:
Real-time availability: MIDAS provides real-time availability of rooms, so users can always see which rooms are available and book them quickly and easily.
Group booking: MIDAS makes it easy for users to book rooms for groups, so they can easily coordinate their schedules and ensure that everyone has a space to meet.
Reporting: MIDAS provides detailed reports on room usage, so businesses can track their spending and make informed decisions about how to allocate their resources.
Integrations: MIDAS integrates with a variety of other business systems, so users can easily manage their room bookings from within their existing workflows.
MIDAS is a powerful and flexible room booking software that can help businesses and organizations of all sizes save time and money. With MIDAS, users can easily book rooms, track room availability, and manage room reservations. MIDAS also offers a variety of features that can help businesses save time and money, such as real-time availability, group booking, reporting, and integrations.
Here are some of the benefits of using MIDAS room booking software:
Save time and money: MIDAS can help businesses save time and money by automating the room booking process. With MIDAS, users can easily book rooms, track room availability, and manage room reservations. This can free up staff time to focus on other tasks, and it can also help businesses avoid overbooking and underutilizing their meeting and event spaces.
Improve efficiency: MIDAS can help businesses improve efficiency by providing a centralized platform for managing room bookings. With MIDAS, users can easily see which rooms are available, book rooms, and track room reservations. This can help businesses avoid the hassle of manually tracking room availability and booking rooms.
Increase collaboration: MIDAS can help businesses increase collaboration by providing a platform for users to share information about room bookings. With MIDAS, users can easily see which rooms are available, book rooms, and track room reservations. This can help businesses ensure that everyone is on the same page when it comes to meeting and event planning.
Overall, MIDAS is a powerful and flexible room booking software that can help businesses and organizations of all sizes save time and money. With MIDAS, users can easily book rooms, track room availability, and manage room reservations. MIDAS also offers a variety of features that can help businesses improve efficiency and increase collaboration.
– Bard
Our thoughts…
We have to admit that on this occasion, we preferred Google Bard’s response. It was certainly a more in depth summary of our MIDAS software.
ChatGPT’s response – whilst concise – was a little misleading. It claimed that “MIDAS” stands for “Meeting Room Scheduling”.
Whilst MIDAS is indeed a meeting room scheduling system, the acronym “MIDAS” itself doesn’t stand for “Meeting Room Scheduling”. For a clue as to what MIDAS does stand for, see this blog post.
AI chatbots are certainly having a bumpy ride of late.
Back in February this year, $100bn was wiped off Google’s parent company, Alphabet’s shares, after Bard made a mistake and investors became nervous.
When two big rivals – Google and Microsoft – both launch competing AI ChatBots, the race is on. Yet many are warning that we need to slow down AI development and ensure that ethics are taken into account.
In the fifteen plus years that we’ve been developing MIDAS, we’ve seen (and implemented) numerous technological advances. It’s exciting – if not also a little scary – to think where the advancements in AI might take us in just a few year’s time.
UPDATE: January 2024: We’ve used AI for the first time to help optimize some of our MIDAS code! Read more about this in our optimizing code with AI blog post.
Our MIDAS room scheduling software allows your customers to pay invoices online for the hire of your rooms, facilities, and resources.
This feature was first introduced back in 2010 with MIDAS v3.10. Since then, we’ve natively supported payment of invoices using either PayPal or Google Checkout.
Unfortunately, as of MIDAS v4.07 we have now removed – the now defunct – Google Checkout support from our software.
Google Checkout first came into being in 2006 with the aim of simplifying the process of paying for online purchases. Users would store their credit or debit card and shipping information in their Google Account. This allowed them to make purchases without having to re-enter their information each time, and secure in the knowledge that their card details wouldn’t be made available to the seller.
Transaction fees for using Google Checkout were initially free. However, as one of PayPal‘s main competitors, over time the transaction fees for using Google Checkout became identical to PayPal’s fees. Many of the each platform’s features also aligned, such as providing fraud protection and the ability for customers to track purchases.
Whilst PayPal and Google Checkout were in direct competition offering quite similar services, there were a number of differences.
On the plus side, once a merchant received a payment via Google Checkout it would be automatically withdrawn to the merchants bank account. PayPal, on the other hand, required merchants to manually withdraw funds to their bank account. On the downside, whilst PayPal supported transactions in multiple currencies; Google Checkout only accepted payments in the currency that the merchant’s bank account was in. It was not possible for Google Checkout merchants to accept multiple currencies.
Google Checkout Becomes Google Wallet
In 2011, Google then announced a “rebrand” of Google Checkout to “Google Wallet”, but the services offered remained the same.
However, in late November 2013, Google Checkout was discontinued and the nature of “Google Wallet” shifted.
Google Wallet has now become a method for making and accepting payments exclusively for apps and in-app purchases via the Google Play Store. It can no longer be used as an online payment processor for anything else.
Due to this new direction in which Google have taken their Google Wallet service, the previous functionality we were able to offer in MIDAS – the ability for clients to pay their invoices online using Google Checkout/Wallet – now no longer works. We have therefore removed all Google Checkout/Wallet integration as of MIDAS v4.07.
We hope Google reconsider their stance to provide online payment processing solely for their own Google App Store. The more choice there is for both consumers and merchants alike the better. That said, there are numerous other online payment processors that have sprung up in recent times. These include notable solutions such as Amazon Payments and Stripe. Incidentally, Stripe is now our preferred card payment processor for purchases made through our website.
Going forward, we continue to support PayPal as a method to allow your clients to directly pay their invoices online for use of your rooms/facilities. In fact, we’ve also improved this support for v4.07 too! If you allow clients to pay invoices online via PayPal, PayPal can now automatically update the status of their MIDAS invoices once payment has been made. This means that you’ll no longer have to manually update invoices yourself! For more information, please see: Configuring PayPal Integration
We’re also keen to hear from you! Are any other online payment processors you’d like us to consider supporting in future updates to MIDAS? We can’t promise we’ll natively support them, but we’d love to hear from you!
Now, twelve months on, and less than a week since Internet Explorer 11 became available for Windows 7, Firefox celebrated its ninth birthday, and just a day after Google Chrome 31 is released, we decided it was high time to once again put the latest web browsers offerings “head-to-head” and independently, rigorously test and benchmark them to find out which one of the five major browsers is currently “the best”….
Browsers Tested
Google Chrome 31
Mozilla Firefox 25
Internet Explorer 11
Opera 17
Apple Safari 5
The Tests
We broadly tested four key areas of browser performance: Speed, Memory Usage, Compliance with standards, and Javascript Performance.
1. Speed
The “Cold Start” test measures the time taken to load up the browser upon its first run after a computer reboot. This is measured from the point at which the browser is executed until the point at which its user interface (UI) is ready to accept input.
The “Non-Cold Start” test measures the time taken to load up the browser on second and subsequent runs after its first run after a reboot. This is measured from the point at which the browser is executed until the point at which the user interface (UI) is ready to accept input.
With the browser open, an empty cache, and showing a blank page (about:blank), the “Page Load Time (No-Cached Load)” test measures the time taken to completely load a complex web page. This is measured from the point at which the “Enter” key is pressed on the URL in the browser’s address bar until the point at which the test web page has fully loaded (as reported by an “onLoad” event on the test web page).
With the browser open, and the test web page already loaded in a single tab, the “Page Load Time (Reload from Cache)” test measures the time taken to reload a complex web page. This is measured from the point at which the F5 key (refresh) is pressed until the point at which the test web page has fully reloaded (as reported by an “onLoad” event on the test web page).
2. Memory Usage
The “Base Memory Usage (Blank Tab)” test measures the amount of memory used by the browser with just a single blank (about:blank) tab open.
The “Memory Usage (10 open tabs)” test measures the amount of memory used by the browser with 10 tabs open, each displaying the home page of a popular website.
3. Compliance
The “HTML5 Compliance” test measures how well each browser conforms to the current state of the HTML5 specification.
The “CSS3 Compliance” test measures how well each browser conforms to the current state of the CSS3 specification.
4. Javascript Performance
There are a number of different Javascript Performance Benchmark tests available today, all of which give quite different results. We’ve analyzed results from 6 of the most popular Benchmarking Tests and aggregated the results below:
Individual details of each of the 6 individual Javascript benchmark test suits used to arrived at these aggregated scores may be found in our full test report, available to view/download at the end of this page.
Summary
Category
Test
Winner
Runner-Up
Speed
Cold Start
Non-Cold Start
Page Load Time (Non-Cached Load)
Page Load Time (Reload from Cache)
Memory Usage
Base Memory
10 Open Tabs
Compliance
HTML5
CSS3
Performance
Javascript Performance (Aggregate)
Results
1st Place
2nd Place
3rd Place
4th Place
5th Place
Google Chrome 31
Opera 17
Internet Explorer 11
Mozilla Firefox 25
Apple Safari 5
The above overall positions were derived based upon the sum of the positions that each browser finished in, in each of our tests. For example, in our HTML 5 compliance test, Chrome came first and so was assigned 1 point, Safari came 5th and so was assigned 5 points. Browsers were then ranked according to the lowest number of points to give the 1st-5th places above (1st being the best)
Analysis
Google Chrome When we last tested the five major browsers back in November 2012, Chrome came first in 8 out of 13 our tests, making it a clear winner! A year later, and Chrome is still going strong, coming top in 8 out of 15 tests, and second in a further two tests. Where Chrome still doesn’t perform quite as well is when it comes to its memory usage, using well over 3 times as much memory with a single blank tab open than Internet Explorer 11.
Mozilla Firefox We were a little surprised that Firefox only came top in 3 out of 15 tests, and only once came runner-up. To Firefox’s credit, its main strength still seems to be in its memory usage. With 10 websites open in separate tabs, the amount of memory used was less than half that of Chrome with the same ten sites open.
Internet Explorer We were pleasantly surprised by the improvement of Internet Explorer 11 over previous versions as well as other browsers. IE11 came top in a couple of our tests, and runner-up in a further three. Where IE11 appears to have improved most over earlier versions of Microsoft’s browser in is the length of time taken to load and pages (either from a server, or from the cache) as well as start/restart the browser itself. In our tests, starting IE11 took just 0.01463 seconds! – some 280x quicker than Opera started. That said, in general Internet Explorer 11 still has a way to go to come up to par with the other major browsers in terms of HTML 5 compliance.
Opera A lot has changed with Opera since we last tested browsers twelve months ago. Since then, Opera have switched from using their own “Presto” layout rendering engine to instead using the same engine as Chrome. Whilst this change has been received with mixed reviews by Opera users, with some unhappy that many of Opera’s original features were dropped, our test results actually show that the “new” Opera is a browser to be reckoned with, out performing Internet Explorer 11, Firefox 25 and Safari 5 in our tests. Opera 17 came top in 3 out of our 15 tests, and runner-up in 6. The browser also scored highly on HTML5/CSS3 compliance and in our aggregated Javascript performance tests, however, Opera’s memory usage was fairly high, second only to Chrome. Opera 17 was slow to start, however, once running it loaded and rendered web pages swiftly.
Safari Our browsers tests were performed on a Windows machine (test specifics are included at the end of this report). Whilst the latest version of Safari is 7, Apple took the decision after the release of Safari 5.1 to no longer continue developing Safari for Windows users – a mistake in our view! Therefore, the most recent version of Safari available to Windows users is 5.1.7, which was used in our testing. Given that Safari 5.1.7 is now the oldest of the 5 browsers tested, it follows that is doesn’t perform as well as its peers. However, surprisingly, it did come runner-up in both our memory tests as well as our non-cold start test.
Conclusions – From a Developers Perspective
From our perspective, as developers of a leading web-based room booking and resource scheduling solution, perhaps the most important factors in determining which browser is “best” are compliance with the latest HTML5 and CSS3 standards. As we work hard to ensure our software works well in all the major browsers, this is where having universal standards between browsers becomes so important. In theory, a website (or in our case, a web app), should look and behave the same regardless of the browser being used, which should in theory happen if all browsers complied 100% with standards! Chrome 31 currently comes the closest to the HTML 5 standard with 93% compliance, but as can be seen, CSS3 compliance still has a long way to go for all browsers, with the winning browser in the CSS3 compliance test (Opera 17) only achieving 58% compliance.
Speed (page load time) and Javascript Performance are also important factors for us, as we want our web app to be as fast and responsive as possible. Opera 17 and Chrome 25 loaded pages faster in our tests, with Internet Explorer 11 following close behind. As for performance, both Chrome 25 and Opera 17 outperformed other browsers in our aggregated Javascript performance test scores.
A few surprising finds:
Microsoft have made some significant steps forward with Internet Explorer 11 over earlier incarnations of their browser.
Opera 17 performed better than expected
Firefox 25 performed worse than expected, finishing an overall 4th place in our tests.
MIDAS, our popular Browser-Based Room & Resource Scheduling Software is currently supported in all browser versions we’ve tested here. Find out more at https://mid.as
Conclusions – So which browser should I use then!?
• If you work with lots of browser tabs open at once, and/or the amount of available memory on your system is limited, Firefox 25 would seem a good choice of browser to use, as this used the less memory than other browsers under the same conditions.
• If you regularly open and close your browser, Internet Explorer 11 or Firefox 25 would seem a good choice as these browsers start up quickly. If, however, you tend to keep your browser running most of the time, Opera 17 would be a better choice, as even though its start-up time is considerably longer, initial page load times are the quickest of all the browsers we tested
• If you’re still using an earlier version of Internet Explorer – it’s certainly worth upgrading to IE11, or if that’s not possible (for example, if you’re using Windows XP, you won’t be able to update your Internet Explorer past version 8!), maybe it’s time to try a different browser!?
• At the end of the day, use the browser that you feel most comfortable with! …BUT make sure you keep it up-to-date, and don’t ignore the competition – if you do, you risk being left behind as other browsers overtake yours in terms of their speed, security, memory usage, standard compliance, and performance!
• In recent years, browsers such as Internet Explorer and Opera have been somewhat overlooked by many regular internet users – but if you’ve not used these browsers for years having previously dismissed them – a lot has changed, and it’s certainly worth giving them a second look again now!
Browsers Tested: Chrome 31.0.1650.48 m | Firefox 25.0 | Internet Explorer 11.0.9600.16428 | Opera 17 (Build 1652) | Safari 5.1.7 (7534.57.2)
Browser tests were performed on an Intel® Atom™ CPU D525 @ 1.80GHz system, with 4GB Ram, running Windows Home Server 2011 SP1 (Windows Server 2008 R2) 64-bit. Each browser was a clean install, using default install and browsers settings, and with no extensions/addons installed or enabled.
Speed tests were measured using Rob Keir’s millisecond timer and PassMark AppTimer v1.0. Each speed test was performed 10 times for each browser, and the results averaged to provide the data presented in this report.
Memory usage was measured 60 seconds after tabs had finished loading and was measured through the Windows Task Manager. Memory usage includes all associated processes running with the browser (for example, running Safari spawns both “Safari.exe” and “WebKit2WebProcess.exe” processes, the memory usage of both is taken into account)