GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
speed.c
Go to the documentation of this file.
1
/*
2
** Written by David Gerdes US Army Construction Engineering Research Lab
3
** April 1992
4
** Copyright 1992 USA-CERL All rights reserved.
5
**
6
*/
7
8
/*
9
** This is a simple best case performance comparison between linkm and malloc
10
*/
11
#include <stdio.h>
12
#include <grass/linkm.h>
13
14
struct
link
15
{
16
char
let
;
17
struct
link
*
next
;
18
};
19
20
/*
21
#define LINKM
22
*/
23
24
int
main
(
int
argc,
char
*argv[])
25
{
26
register
int
i;
27
VOID_T
*head;
28
struct
link
List, *tmp, *p;
29
int
rev = 0;
30
31
32
33
#ifdef LINKM
34
head = (
VOID_T
*)
link_init
(
sizeof
(
struct
link
));
35
#endif
36
37
38
for
(i = 0; i < 2000000; i++) {
39
#ifdef LINKM
40
p = (
struct
link
*)
link_new
(head);
41
link_dispose
(head, p);
42
#else
43
p = (
struct
link
*)malloc(
sizeof
(
struct
link
));
44
free(p);
45
#endif
46
}
47
48
#ifdef LINKM
49
link_cleanup
(head);
50
#endif
51
52
exit(0);
53
}
lib
linkm
speed.c
Generated on Thu Sep 26 2013 09:48:06 for GRASS Programmer's Manual by
1.8.4