summaryrefslogtreecommitdiff
path: root/pjlib/src/pjlib-test/pool_perf.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-05-01 10:42:22 +0000
committerBenny Prijono <bennylp@teluu.com>2007-05-01 10:42:22 +0000
commite4d10ec39863e84681c5b685d8b46e9c7351f5b4 (patch)
tree13a15887b866bbdf7c24431e45ab7e8d0f22ce4d /pjlib/src/pjlib-test/pool_perf.c
parentf9b1f6fe23396291bc504e850dfe98ea5647ed9e (diff)
Ported PJLIB and PJLIB-TEST to Symbian!
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1238 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pjlib-test/pool_perf.c')
-rw-r--r--pjlib/src/pjlib-test/pool_perf.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/pjlib/src/pjlib-test/pool_perf.c b/pjlib/src/pjlib-test/pool_perf.c
index 6fb341e0..c65b6e40 100644
--- a/pjlib/src/pjlib-test/pool_perf.c
+++ b/pjlib/src/pjlib-test/pool_perf.c
@@ -60,6 +60,35 @@ static int pool_test_pool()
return 0;
}
+/* Symbian doesn't have malloc()/free(), so we use new/delete instead */
+#if defined(PJ_SYMBIAN) && PJ_SYMBIAN != 0
+
+static int pool_test_malloc_free()
+{
+ int i; /* must be signed */
+
+ for (i=0; i<COUNT; ++i) {
+ p[i] = new char[sizes[i]];
+ if (!p[i]) {
+ PJ_LOG(3,(THIS_FILE," error: malloc failed to allocate %d bytes",
+ sizes[i]));
+ --i;
+ while (i >= 0)
+ delete [] p[i], --i;
+ return -1;
+ }
+ *p[i] = '\0';
+ }
+
+ for (i=0; i<COUNT; ++i) {
+ delete [] p[i];
+ }
+
+ return 0;
+}
+
+#else /* PJ_SYMBIAN */
+
static int pool_test_malloc_free()
{
int i; /* must be signed */
@@ -84,6 +113,8 @@ static int pool_test_malloc_free()
return 0;
}
+#endif /* PJ_SYMBIAN */
+
int pool_perf_test()
{
unsigned i;
@@ -140,6 +171,10 @@ int pool_perf_test()
best = pool_time, worst = pool_time2;
else
best = pool_time2, worst = pool_time;
+
+ /* avoid division by zero */
+ if (best==0) best=1;
+ if (worst==0) worst=1;
PJ_LOG(3, (THIS_FILE, "..pool speedup over malloc best=%dx, worst=%dx",
(int)(malloc_time/best),