alloc tests

This commit is contained in:
Kolan Sh 2011-04-28 14:42:44 +04:00
parent 7c309f9481
commit 6e87b9ffc9
3 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,14 @@
#include <stdlib.h>
const unsigned long long MAX_I=0x00ffffff;
int main()
{
unsigned long long i;
for (i = 0; i < MAX_I; i++)
free(malloc(1));
return 0;
}

7
c/malloc_speed_test/run.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
echo "malloc_speed_test.c test:"
cc -O2 malloc_speed_test.c -o malloc_speed_test && time ./malloc_speed_test
echo -e "\n\nvector_add.cpp test:"
c++ -O2 vector_add.cpp -o vector_add && time ./vector_add

View File

@ -0,0 +1,17 @@
#include <vector>
using namespace std;
const unsigned long long MAX_I = 0x00ffffff;
int main()
{
unsigned long long i;
vector<char> v;
for (i = 0; i < MAX_I; i++)
v.push_back(0);
return 0;
}