我试图将字符串从Flash复制到RAM,但这会导致垃圾。
const char string[] PROGMEM = "ABCDEF";
char buffer[20];
char *ptr = (char*)pgm_read_word(&(string));
strcpy_P(buffer, ptr);
我错过了什么?
答案 0 :(得分:0)
import timeit
from datetime import datetime
from pendulum import datetime as pendulum_datetime
from rfc3339 import rfc3339
dt = datetime(2011, 11, 4, 0, 5, 23, 283000)
pendulum_dt = pendulum_datetime(2011, 11, 4, 0, 5, 23, 283000)
repeats = 10**6
print('datetime strftime')
func1 = lambda: datetime.strftime(dt, "%Y-%m-%dT%H:%M:%S.%f%z")
print(func1())
print('Time for {0} loops: {1}'.format(
repeats, timeit.timeit(func1, number=repeats))
)
print('cast to string')
func2 = lambda: str(dt)
print(func2())
print('Time for {0} loops: {1}'.format(
repeats, timeit.timeit(func2, number=repeats))
)
print('datetime isoformat')
func3 = lambda: datetime.isoformat(dt)
print(func3())
print('Time for {0} loops: {1}'.format(
repeats, timeit.timeit(func3, number=repeats))
)
print('pendulum to_iso8601_string')
func4 = lambda: pendulum_dt.to_iso8601_string()
print(func4())
print('Time for {0} loops: {1}'.format(
repeats, timeit.timeit(func4, number=repeats))
)
print('rfc3339')
func5 = lambda: rfc3339(dt)
print(func5())
print('Time for {0} loops: {1}'.format(
repeats, timeit.timeit(func5, number=repeats))
)