Arm Cortex-M vs ESP32: Which is More Efficient?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello my name is gary sims and this is gary explains and we often talk about the performance of let's say desktop processors from intel or from amd or gpus from nvidia and from amd we might even talk about you know smartphones and the latest processor from qualcomm or from apple or from samsung and we talk about their performance sometimes you talk about their power efficiency there is another whole category of processors where it is important to talk about the performance and the power efficiency and that's with microcontroller boards so we're talking you know the raspberry pi pico with all the arduinos stm32 blackpill bluepill we're talking about the esp32 systems so in this video i want to look at the performance and the power usage of the different processors that we get in micro controller systems so if you want to find out more please let me explain [Music] because when it comes to 32-bit micro controller systems there are two main companies that are making uh cpus at the moment we'll talk about risk five at the end of the video but we're taking about arms cortex m m for microcontroller and you've got a whole series of processes that are basically have different numbers and the higher the number the more features and the more performance you get so at the low end you've got the quartus m0 plus and that's what you find in the raspberry pi pico for example then you've got the cortex m3 the m4 the m7 and these you might find in the blue pill the black pill and so on now you've also got the esp32 systems they're built on the 10 silica extensor lx6 processor which is a custom processor by cadence systems and it really is designed for just uh embedded systems you won't hear about that you know in laptops or or anything like that and they've been very very popular this esp32 systems which include wi-fi bluetooth and these cpus are very very popular particularly for bores that come directly from china now of course the first thing we have to say is that these are all different of course the extensor cpu is very different to an arm cpu and even arm cpus are the same type of cpu and different boards might have different characteristics because of frequency because of the speed of the buses the speed of the ram the speed of the flash how much caching they've put into it and so on so not everything is equal just because it says it's an m3 or a quarter's m4 doesn't mean it'd be the same as some other caught it's m3 or m4 from another manufacturer and just because the esp32 says it's running at 240 megahertz does that mean necessarily that it's fast or has better power efficiency or whatever and that's what we're going to look at which has the greatest performance which uses the less power which one has the greatest power efficiency how much can it get done using a particular amount of power okay so let's dive straight in okay so to test out the performance of the cpu on these microcontroller boards i created a very simple test that uses trial by division not the most efficient way of finding primes but i intentionally did that so it deliberately goes through the first million numbers to try to find uh all the primes are in that first million and the test is surprisingly repeatable across all of the boards whether it's an esp32 whether it's an stm32 whether it's the raspberry pi pico the results always come back the time taken within within one millisecond now i'm using the arduino ide rather than using you know a specific one for stm32 a specific one for esp i'm using the ide from arduino and i'm using the same sketch the same code reach ball i just change the board compiler and just say compile it for this board i've got the right official packages installed and i use -03 whenever that's available as i said very repeatable there's it's always the same now if this video is interesting and people would like to see i'm more than happy to develop a greater range of benchmarks not just as trial by division maybe more some in memory intensive more some cpu intensive floating point intensive if you would like to see that kind of thing then please do let me know in the comments below okay so here is our first graph and there's going to be quite a few graphs for us to go through because it really is the easiest way to understand the numbers of visual representation and basically this is the time it takes in milliseconds to run that test to find the happens to be 78 497 primes in the first million integers and as we can see uh the slowest is the blue pill and that's got the cortex m3 running at 72 megahertz it takes around 42 seconds to find all those numbers and there's quite a leap down when we go up to the um the black pill which got the quarters m4 running at 100 megas is actually the uh magma splash which is the black billboard built in europe and i've got a video about that here on this channel then next is the raspberry pi pico running at 133 megahertz and that takes about 18 seconds so these are the slower ones we're running uh in the 100 megahertz or less kind of area 7200 133 and then there's you go from eighteen seconds to nine seconds so here's a big leap in performance so when you go to the esp32 running at 240 megahertz so quite a faster than these other ones that only takes nine seconds and in fact if you use the stm uh cortex m7 discovery board then that actually only takes 8.3 seconds so a second faster while actually only running at 216 megahertz compared to 240 so the esp32 puts in a very strong performance and it certainly beats the cortex m0 they call it's m3 they call it m4 but it is beaten by the cortex m7 in terms of raw performance how long does it take to do that calculation but of course this is the thing the uh clock speeds are very different so they some stuff could be hiding around here you know what happens if the raspberry pi could be clocked faster well actually it can what happens if the esp32 would run slow it will in fact it can so we can actually fiddle with the clock speeds and get uh some different numbers so that's what i've did let's look at some different numbers physically changing the clock speed in software to make it run so here's a whole bunch of different numbers so the slowest here uh just a bit slower than the blue pill running at its native 72 megahertz is the cortex m0 in the pico running at 50 megahertz that takes 48 seconds 42 seconds if you slow down the esp 32 to 80 megahertz then that comes in at 28 seconds so while the bloop is running at 72 megahertz when you run this one at 80 very close number you can see a significant performance there so the esp32 for doing very well 100 megahertz for the black pill again remaining at is 22 seconds uh here's the reference point the p co running it's 133 megahertz if you run the esp3260 mega so these are quite close in clock speed 14 seconds versus 18 so you can see there's not too much of a difference between these two in fact we'll narrow that down more precisely in a minute but here's the interesting one you can actually overclock the raspberry pi pico to 240 megahertz so you've got both of them running now at 240 minutes 9.3 seconds versus 9.9 seconds so the raspberry pi pico just a tiny tad slower than the esp32 and of course still the winner running at its native 216 megahertz was the uh cortex f7 there in the discovery board so that's an interesting thing this one particularly when you bring the picot in the esp32 to a similar clock speed you're actually getting similar performance now of course we can now extrapolate and interpolate and actually work out how much you perform performance you get per megahertz so what i did i took all those numbers and then worked out what if they were all just running at one megahertz what would be the speed we're getting now it's not perfect because obviously the cpu may run at one speed but then you've got buses and you've got ram access and flash access they're going to be at different speeds just depending on how the system is uh designed however when i've done my actual physical measuring here with actually you know changing the clock speed and the numbers i get in a minute they're pretty close taking into account there are going to be buses running at different speeds so let's have a look at those numbers so here we are so this is what the the speed is how long it would take to find all those uh prime numbers if it was running at one megahertz okay much much bigger numbers look at much much much bigger numbers but what we find is in third place we have the magma splash black pill with the m4 processor running inside of it 2.2 million milliseconds then in second place we've got the esp32 running at two point two four two point two five two point two four uh milliseconds notice here we've got the two point three nine uh millions for the pico so again you can see now that when you work it out on a per megahertz basis these three chips are pretty close uh in fact but you still get the cortis m7 winning there at 1.8 million milliseconds so that's the overall winner whichever way we slice it up but we can see here there is a good performance a parity between a cortex m4 and the esp32 and the uh called it's m0 plus is not too far behind now it's just worth mentioning this point that not all cortex m0 plus boards are the same so the pico the rp24 processor in the pico seems to be particularly uh good uh and well optimized these other two boards that i've tested here one is the mkr1000 this is an official board from uh arduino that's an official arduino bomb is the jade pebble that's also made here in europe uh available from the same uh company that makes that magma splash the black pill one this is that both of these use the micro chip at sam d21 which is a cortex m0 cpu running at 48 megahertz as you can see though there's the mkr 1000 there is the pebble but as you can see there's a huge difference in performance between these two chips using the uh these two boards using the at sam and the raspberry pi pico so not all quartet m0 cores are the same here we're talking process node caching bus speeds ram speeds flash speeds whole bunch of things that are put together the the fabric that ties it all together how well does it do and clearly the rp2040 is a much superior chip to the d21 okay so that's performance so we we can see that the quartus m7 and the esp32 do a great job in terms of raw performance i want this done quickly but of course there's also a measure of how much current is being used it's possible to measure the current on a board using ohm's law and measuring the voltage drop across a shunt but it's important to know a couple of things this is measuring the power of the board not of the individual microprocessors so for example i don't have any leads turned on if i can avoid that and for example balls that have got wi-fi on will automatically use more current because there's a second chip probably on there or extra part of the chip that's being powered to offer wi-fi even though it's not connected even though it's not actually asked to be doing anything it's there and so you'll find the wi-fi boards use more current uh just from the start okay a lot of numbers here but this is the current usage for all the different boards and i've done it at different frequencies just to show you that frequency has a big part to play in terms of the current that's used so the higher the frequency the higher the current the lower the frequency the lower the current that's one of the laws of power consumption that board designers have to take into account if you want greater frequency you're going to use more current it's as simple as that so right down here on the left hand side we can see the jade pebble running at 48 megahertz only using 12 milliamps and the pico if you clock it right down to 50 megahertz only using 13 milliamps what's really interesting though is that the magma splashed with the m4 cores m4 and it is running 20 milliamps while running at 100 megahertz and you look here the pico w which of course has got the wi-fi stuff the mkr-1000 which has got the wi-fi stuff are all using the same kind of power but running at half the clock speed uh and in fact uh even the pico itself running at 133 megas all in this band of 20 up to 25 uh milliamps so the the power efficiency here of the magma splash is pretty impressive so it's right out the bottom but yet running at 100 megahertz so that's that's worth noting and it will actually become a factor uh in a minute we'll see that another thing to notice here is the raspberry pi pico w so that's the one with the silver tin on it here that's actually got the wi-fi chip inside of it that runs at 35 milliamps although the wi-fi isn't connected it isn't asked to be doing anything it is there on the board and powers up and that's distinct from 25 milliamps for the normal pico without the wi-fi so both running at the same clock speed but notice you're going to get a bump in power consumption when you add that wi-fi chip onto the same board it's going to be powered up when you power it on but the real surprise is this when we go right up here to the esp32 running at 240 megahertz which did offer us some raw performance it's a real power hog 69 milliamps well that's way different down here to the to the quarters m4 running only 20 25 35 this thing and also interestingly even if you slow it down to 80 megahertz okay so reduce the speed to a quarter it's still using more power than the raspberry pi pico and obviously more than the raspberry pi the power more than the pico and more than the magma so basically when you look at this the esp32 is quite a power hog when you uh when you run it and even if you take the picowe would overclock it to 240 megahertz it's still only using 49 milliamps compared to the 69 by the esp32 so while the esp32 was able to offer us that good performance it ha it uses power to do that now one thing you'll notice i haven't got the cortex m7 that's because the board that i used uh has a built-in display and there's no way of turning that built-in display off by software or any jumpers or anything and so the the amp producer was just out of this world because it was powering that display and i wasn't about to go and take a pair of cutters and start cutting bits off the board so it's not doesn't feature here in the power uh consumption um numbers so here is the big question if board a only uses 20 milliamps but takes 22 seconds to complete a task but board b uses 69 milliamps but takes nine seconds to complete the task which one's faster so basically this is the magma with the cortex m4 process right this is the esp32 low power consumption but it took 22 seconds to find all those primes this one much higher power consumption but it was one of the fastest uh much faster than the pico much faster than the magma so which board is more efficient well we can do the calculations in milliwatt hours which is a unit of measuring uh power over time and you'll be quite surprised to see the results so here we go uh the lowest power consumption is actually from the magma splash and the raspberry pi pico not the w version just right there almost this one is actually slightly better so this means that if you actually wanted to do this calculation it will draw power from a battery it will draw power from your power supply and it will use 0.63 milliwatt hours to do that calculation but it will take longer than it would for an esp32 to do it but the overall power it uses even though it's taking longer is less and this is the the trick to this how much does it take uh considering time as a factor so if you just said i want to just calculate these primes and use the least power as possible you'd want to use the pico or the magma now though these two here are the uh ones with the e wi-fi built into them and you can see the pico w is slightly more efficient than the esp32 because although it will take longer to do the calculation it uses less energy to do it and as a comparison here we have the blue pill which is quite significantly double the energy used the blue pill is not that efficient at all so if you start handing out the prizes first prize to the magma splash and the pico for their energy efficiency during an intensive compute task second place to the pico w because it is actually slightly more power efficient than the esp32 which comes in in third place so what are our conclusions well the quartus m7 based stm32 discovery board was the fastest even though it's only clocked 216 megahertz again tell me in the comments below should i try and get hold of a quartus m7 board uh maybe another type of stm uh development board without a display on it uh and see what kind of numbers they get that do tell me in the comments below if you think that would be interesting the quartus m4 based black pill has almost the same per megahertz performance as an esp32 though it is clocked at a much lower clock speed and the quartus m0 plus based pico w uses only 35 milliamps to run the test at 133 megahertz whereas the esp32 needs 41 milliamps while running at only 80 megahertz so this is the basis of the fact that the pico w actually is more power efficient and so the most efficient boards are the quartus m4 based black pill and the quarters m0 pico without the wi-fi and then if you add the wi-fi it's still more power efficient than the esp32 okay so there you have it there's my look at the arm processors versus the esp32 i think those conclusions there are pretty solid now i did say we would mention risk five risk five is now starting to turn up in a few uh microcontrollers i've got two on order from different companies using the esp32c3 which is a risk five version of the esp32 hopefully they're going to come in the next few days had all of them from china so it's going to take a little while till they get there once i get those i'm going to do a similar type of video using the esp32 with the risk 5 processor tell me any questions you particularly have about that in the comments below so i can make sure i address those in the video okay that's it my name is gary sims this is gary explains i really hope you enjoyed this video if you did please do give it a thumbs up if you like these kind of videos if you want to watch that video on the risk 5 mac controller then subscribe to the channel and don't forget you can follow me on twitter at gary explains i also have a monthly newsletter go over to gary explains.com type in email address no spam but you will get the newsletter okay that's it i'll see in the next one [Music] you
Info
Channel: Gary Explains
Views: 47,272
Rating: undefined out of 5
Keywords: Gary Explains, Tech, Explanation, Tutorial, Arm, Arm Cortex-M Microcontroller, Microcontrollers, MCU, Cortex-M0+, Cortex-M3, Cortex-M4, Cortex-M7, ESP32, Espressif Systems, Tensilica Xtensa LX6, Microprocessor, CPU, Arduino, Microcontroller board, BluePill, BlackPill, Raspberry Pi Pico, RP2040, MKR1000, ESP32 Dev Kit, ESP32 DOIT DevKit, DOIT Esp32 DevKit, 32-bit, RISC
Id: XJawv8xGtX4
Channel Id: undefined
Length: 19min 41sec (1181 seconds)
Published: Tue Aug 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.