For large trucks, the faster they go, the better the fuel economy due to energy lost by their engines (mainly by heat).
See table 5.12 in https://tedb.ornl.gov/wp-content/uploads/2021/02/TEDB_Ed_39.pdf#page=161
In that report – the best fuel economy was found when over 85mph for trucks! It gets worse the slower you go.
For electric, as there is significantly less energy lost when not moving, slower is generally more efficient (down to very low speeds), but slowing / speeding for speedhumps does lose a lot more energy than constant speed (despite some energy recovery when gently braking).