Posts Tagged: Gemini

Optimizing Source Code with AI

Optimizing Software Code using AI

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
  • Improved scalability: Handling larger workloads effectively
  • Maintainability: Making code easier to understand and modify

Some common source code optimization techniques involve:

  • Algorithm optimization: Choosing more efficient algorithms
  • Loop optimization: Reducing loop iterations or overhead
  • Memory optimization: Minimizing memory usage and allocations
  • Input/output optimization: Streamlining data reading and writing
  • Caching: Storing frequently used data for faster access
  • Compiler optimization: Leveraging compiler features for automatic optimization
  • Profiling: Identifying performance bottlenecks to focus optimization efforts

Code Optimization in MIDAS

Over the years we’ve been developing MIDAS, all our code optimization work has been done manually.

This work has involved attempting to simplify and rewrite parts of the source code to be more efficient.

Code Optimizing with AI

In our latest release, MIDAS v4.35, for the very first time, a small section of source code has been optimized with the assistance of AI (or Artificial Intelligence).

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:

Our Original Subroutine:
30 wallclock secs (30.28 usr + 0.00 sys = 30.28 CPU) @ 330229.18/s (n=10000000)

AI Optimized Subroutine:
27 wallclock secs (27.09 usr + 0.00 sys = 27.09 CPU) @ 369085.41/s (n=10000000)

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.


What AI thinks about MIDAS?

What rivals ChatGPT and Google Bard think about MIDAS

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.

You may have also heard about Google’s rival, “Bard” (now know as “Gemini”), who are also integrating their AI chat bot into their 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.

More recently, a man widely considered to be the “godfather” of Artificial Intelligence, who quit his job at Google, has warned about the growing dangers from developments in the field.

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.

UPDATE: February 2024: “Bard” has now been rebranded as “Gemini”.