Was wondering if I would get more battery life with arch vs.

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

Was wondering if I would get more battery life with arch vs.

Postby pwr33 » Sat Mar 14, 2020 4:39 pm

Was wondering if I would get more battery life with arch vs. raspbian-buster on a pi-zero w

anecdotally on first test on arch I did get noticeably more battery life, but also noticed python 2 & 3 seemed slower on arch ???

the http://roylongbottom.org.uk whetstone test was comparable between both with arch being a little faster

I had already written a little test to drive battery pack to shutdown so installed arch and ran python prog there, the speed is not even consistent between runs on arch. Also noticed a little lag on ssh after you had not touched it for a while but then no lag, almost as though arch being more aggressive on putting devices to sleep or doing more with ipv6 or something?

any ideas?

Code: Select all
import time
from datetime import datetime
sdt = datetime.now()
stime = time.time()
ltime = stime
looptook = 0.0
avglooptook = 0.0
loops = 0
logperiod = 2
i = 0.001
altfile = 0
numfiles = 5
while True :
  lstart = time.time()
  for tloop in range(10000) :
    i += 0.00003
    j = i/3.33
  loops += 1
  ntime = time.time()
  if ntime-ltime > logperiod :
    ltime = ntime
    ndt = datetime.now()
    #logline = "Uptime {:.3f}m Loops {} Loop took {:.07}s".format((ltime-stime)/60,loops,looptook)
    logline = "Uptime {} Progtime {:.3f}m Loops {:4d} Looptime {:.05}s".format(ndt - sdt,(ltime-stime)/60,loops,looptook)
    f = open("batterytest_stress-{:1}.txt".format(altfile),"w")
    altfile += 1
    altfile %= numfiles
    f.write("Test Started at : {}\n".format(sdt))
  looptook = time.time()-lstart



Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2

python2 batterytest_stress.py
Uptime 0:00:02.015962 Progtime 0.034m Loops 54 Looptime 0.037541s
Uptime 0:00:04.036769 Progtime 0.067m Loops 119 Looptime 0.030968s
Uptime 0:00:06.057752 Progtime 0.101m Loops 184 Looptime 0.030922s
Uptime 0:00:08.079742 Progtime 0.135m Loops 249 Looptime 0.031031s
Uptime 0:00:10.101105 Progtime 0.168m Loops 314 Looptime 0.030902s

Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

python3 batterytest_stress.py
Uptime 0:00:02.018973 Progtime 0.034m Loops 52 Looptime 0.038375s
Uptime 0:00:04.048052 Progtime 0.067m Loops 104 Looptime 0.038702s
Uptime 0:00:06.076778 Progtime 0.101m Loops 156 Looptime 0.038679s
Uptime 0:00:08.100243 Progtime 0.135m Loops 208 Looptime 0.039263s
Uptime 0:00:10.124965 Progtime 0.169m Loops 260 Looptime 0.038399s


Python 2.7.17 (default, Oct 24 2019, 00:28:43)
[GCC 8.3.0] on linux2

python2 batterytest_stress.py
Uptime 0:00:02.012300 Progtime 0.034m Loops 42 Looptime 0.047601s
Uptime 0:00:04.058750 Progtime 0.068m Loops 85 Looptime 0.047403s
Uptime 0:00:06.104298 Progtime 0.102m Loops 128 Looptime 0.04741s
Uptime 0:00:08.104641 Progtime 0.135m Loops 170 Looptime 0.047432s
Uptime 0:00:10.150359 Progtime 0.169m Loops 213 Looptime 0.047203s

Python 3.8.2 (default, Mar 7 2020, 17:58:45)
[GCC 9.2.0] on linux

python3 batterytest_stress.py
Uptime 0:00:02.038668 Progtime 0.034m Loops 24 Looptime 0.085331s
Uptime 0:00:04.100178 Progtime 0.068m Loops 48 Looptime 0.084512s
Uptime 0:00:06.151104 Progtime 0.103m Loops 72 Looptime 0.084901s
Uptime 0:00:08.196073 Progtime 0.137m Loops 96 Looptime 0.084601s
Uptime 0:00:10.244030 Progtime 0.171m Loops 120 Looptime 0.08522s
Posts: 5
Joined: Sat Mar 14, 2020 3:21 pm

Re: Was wondering if I would get more battery life with arch

Postby pwr33 » Sun Mar 15, 2020 9:13 pm

so, was wondering if something stupid like latest python auto going to 96 bit floats when it spots going smaller or... wtf???
(If that's the case then sure I can specify type required if that is necessary/possible to override auto...)

difference between python 2 and 3 on arch is major, but quite close in efficiency on raspbian buster
(actually timings would correlate with latest python3 being 64 bit precision vs. 32 bit on python2)

but... I'm all for battery life in this case... enough cpu power for task in hand? yet to be determined...

is raspbian allowing it (pi zero) to go to higher clock speed?

anyway running battery-pack (auto-shutdown at safe li-ion low voltage) wipeout test again on a faster sd card, though sure ruled that (faster sd card) out as cause already...

not much happening here on this subforum... but pi zero is awesome !!!! arch seems cool...

again anecdotally, running python prog and observing chinese usb port power monitor it is hovering under 0.1 amps where raspian was up and down all over the place up to 0.18 or so... I like that it most often seems to display mainly 0.07 amps on the display using arch LOL

on arch while running 100% cpu using stress version seems to be running more around the usb power range of raspbian running a version of same prog that does not do the floating point loop!

yet to do the idle version test on arch... will post results!

So, seems more battery life but slower python performance, much slower in case of python3

tv service off and activity led disabled

===== arch

python3 batterytest_stress
Test Started at : 2020-03-15 14:11:07.883421
Uptime 17:07:31.457308 Progtime 1027.524m Loops 785645 Looptime 0.075874s

python3 batterytest_idle
Test Started at : 2020-03-16 13:18:44.704948
Uptime 23:32:33.112351 Progtime 1412.552m Loops 0 Looptime 30.134s

===== raspbian

python batterytest_stress.py
Test Started at : 2020-03-02 19:30:57.987438
Uptime 11:36:53.514696 Progtime 696.892m Loops 1266074 Looptime 0.032695s

python batterytest_idle.py
Test Started at : 2020-03-03 13:52:07.913898
Uptime 20:31:44.775763 Progtime 1231.746m Loops 0 Looptime 30.134s

python batterytest_idle.py
Test Started at : 2020-03-04 13:41:30.844467
Uptime 21:53:02.451570 Progtime 1313.041m Loops 0 Looptime 30.117s
Posts: 5
Joined: Sat Mar 14, 2020 3:21 pm

Re: Was wondering if I would get more battery life with arch

Postby pwr33 » Mon Mar 23, 2020 8:11 pm

OK so rewrote the test in C doing exactly the same floating point ops but also printed the resultant value regularly to avoid the actual floating point ops being optimised away if the result never used LOL

Will test arch again twice on each battery pack to see if that was where difference can be accounted for

results, C is much faster..., arch seems to get bit more battery life... can't see what is happening on wifi perhaps extra stress...

=== arch

batterytest_stress.c Started at 20200321-142853
20200322-092331.789, Uptime 18h54m38s Loops 808451185, Looptook 0.0000819980 value 72843744.07
batterytest_stress.c Started at 20200321-142853
20200322-092329.789, Uptime 18h54m36s Loops 808427392, Looptook 0.0000829990 value 72841599.78

=== raspbian

batterytest_stress.c Started at 20200321-142904
20200322-072114.637, Uptime 16h52m10s Loops 736415361, Looptook 0.0000819990 value 66351663.91
batterytest_stress.c Started at 20200321-142904
20200322-072112.637, Uptime 16h52m08s Loops 736391083, Looptook 0.0000809990 value 66349475.90
Posts: 5
Joined: Sat Mar 14, 2020 3:21 pm

Re: Was wondering if I would get more battery life with arch

Postby pwr33 » Sun Mar 29, 2020 7:45 pm

ok, so two more tests using arch on both battery packs seems to show bit better battery life, I reckon possibly also need to have a sniffer seeing what is going on on wifi (I mean not of my creation)... but both show bit (5+%) better than the buster test

however, did have a fatal python crash locked up ssh session where I would not expect that failure mode on raspbian....

===== batterytest arch - battery1

batterytest_stress.c Started at 20200324-145745
20200325-083333.125, Uptime 17h35m48s Loops 751465114, Looptook 0.0000819990 value 67707991.88
batterytest_stress.c Started at 20200324-145745
20200325-083331.124, Uptime 17h35m45s Loops 751441324, Looptook 0.0000819990 value 67705847.85

===== arch battery pack 2

batterytest_stress.c Started at 20200325-133304
20200326-072144.504, Uptime 17h48m40s Loops 752911521, Looptook 0.0000830000 value 67838346.33
batterytest_stress.c Started at 20200325-133304
20200326-072142.503, Uptime 17h48m38s Loops 752888001, Looptook 0.0000829990 value 67836226.64
Posts: 5
Joined: Sat Mar 14, 2020 3:21 pm

Return to Raspberry Pi

Who is online

Users browsing this forum: Ynkwhlr and 3 guests