memtest.c
#include <string.h>
#include <sys/time.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
#include <stdio.h>
#define ONE_MILLION 1000000
#define MEM_TEST_SIZE (100 * ONE_MILLION)
int main(int argc, char* argv[])
{
if (argc < 2)
{
printf("usage: %s n (test n mega bytes)\n", argv[0]);
exit(-1);
}
int n = abs(atoi(argv[1]));
printf("now test copy %dM bytes.\n", n);
uint8_t *src = (uint8_t *)malloc(n * ONE_MILLION);
uint8_t *dst = (uint8_t *)malloc(n * ONE_MILLION);
if(!src || !dst)
{
printf("alloc memory error!\n");
exit(-2);
}
struct timeval time_start;
struct timeval time_end;
gettimeofday(&time_start,NULL);
memcpy(dst, src, (n * ONE_MILLION));
gettimeofday(&time_end,NULL);
printf("calculate time: %ld us \n",
(ONE_MILLION * time_end.tv_sec + time_end.tv_usec)-(ONE_MILLION*time_start.tv_sec + time_start.tv_usec)
);
free(dst);
free(src);
return 0;
}
VMWARE + Ubuntu 18.04 测试:
$
$ ./memtest 1
now test copy 1M bytes.
calculate time: 665 us
$
$ ./memtest 10
now test copy 10M bytes.
calculate time: 6692 us
$
$ ./memtest 100
now test copy 100M bytes.
calculate time: 67354 us
离线
V3s DDR2
CPU 1GHz, DDR CLK 360MHz
# memtest 1
now test copy 1M bytes.
calculate time: 4300 us
#
#
#
# memtest 10
now test copy 10M bytes.
calculate time: 50673 us
#
#
#
# memtest 15
now test copy 15M bytes.
calculate time: 82828 us
离线
V3s DDR3 (相当于S3)
CPU 1GHz, DDR CLK 360MHz
# memtest 1
now test copy 1M bytes.
calculate time: 2458 us
#
# memtest 10
now test copy 10M bytes.
calculate time: 24788 us
#
#
# memtest 15
now test copy 15M bytes.
calculate time: 37431 us
#
# memtest 3
now test copy 3M bytes.
calculate time: 7528 us
#
#
# memtest 3
now test copy 3M bytes.
calculate time: 7294 us
#
#
# memtest 3
now test copy 3M bytes.
calculate time: 7329 us
同频率下,DDR2比DDR3快了一倍多.
离线
还有这回事,ddr3为什么会慢过ddr2
离线
还有这回事,ddr3为什么会慢过ddr2
不好意思, 前面写错了。应该是同频率下,DDR3比DDR2快了一倍多.
离线
#
# ./memtest 1
now test copy 1M bytes.
calculate time: 4373 us
#
#
# ./memtest 2
now test copy 2M bytes.
calculate time: 9216 us
#
# ./memtest 3
now test copy 3M bytes.
calculate time: 13578 us
#
# ./memtest 10
now test copy 10M bytes.
calculate time: 44411 us
#
# ./memtest 15
now test copy 15M bytes.
calculate time: 67031 us
#
# ./memtest 30
now test copy 30M bytes.
calculate time: 133734 us
#
# ./memtest 50
now test copy 50M bytes.
calculate time: 221139 us
#
奇怪, 为什么X3 比 V3s DDR3版本(S3) 更慢?
CONFIG_DRAM_CLK=552
CONFIG_DRAM_ZQ=15291
# CONFIG_DRAM_ODT_EN is not set
CONFIG_SYS_CLK_FREQ=1008000000
最近编辑记录 uuid (2021-01-28 19:15:59)
离线