SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
SET(VERSION 0.1.0)
-SET(SRCS rua.c)
+SET(SRCS
+ src/perf-measure.c
+ src/rua.c
+)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua.h DESTINATION include/${PROJECT_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/rua_db.sql DESTINATION /opt/share/)
+
+#ADD_SUBDIRECTORY(test)
+++ /dev/null
-librua (0.1.0-33) unstable; urgency=low
-
- * Initial Release.
- * Git: pkgs/l/librua
- * Tag: librua_0.1.0-33
-
- -- Jinwoo Nam <jwoo.nam@samsung.com> Sat, 17 Mar 2012 16:52:46 +0900
+++ /dev/null
-Source: librua
-Section: libs
-Priority: optional
-Maintainer: Jinwoo Nam <jwoo.nam@samsung.com>
-Build-Depends: debhelper (>= 5), libsqlite3-dev, libslp-db-util-dev, sqlite3
-Standards-Version: 3.7.2
-
-Package: librua-dev
-Section: libs
-Architecture: any
-Depends: librua-0 (= ${Source-Version}), libsqlite3-dev, libslp-db-util-dev, sqlite3
-Description: recently used applcation library (development)
-
-Package: librua-0
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, sqlite3
-Description: recently used application library (shared object)
-
-Package: librua-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, librua-0 (= ${Source-Version})
-Description: recently used application library (unstripped)
+++ /dev/null
-usr/bin
-usr/sbin
+++ /dev/null
-CMakeLists.txt
+++ /dev/null
-@PREFIX@/lib/*.so.*
-/opt/share/*
+++ /dev/null
-#!/bin/sh
-
-mkdir -p /opt/dbspace/
-sqlite3 /opt/dbspace/.rua.db < /opt/share/rua_db.sql
-rm -rf /opt/share/rua_db.sql
-
-if [ ${USER} = "root" ]
-then
- chown root:5000 /opt/dbspace/.rua.db
- chown root:5000 /opt/dbspace/.rua.db-journal
-fi
-
-chmod 660 @DATADIR@/dbspace/.rua.db
-chmod 660 @DATADIR@/dbspace/.rua.db-journal
-
-
+++ /dev/null
-@PREFIX@/include/*
-@PREFIX@/lib/pkgconfig/*.pc
-@PREFIX@/lib/*.so
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-CFLAGS ?= -Wall -g
-LDFLAGS ?=
-PREFIX ?= /usr
-DATADIR ?= /opt
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
-
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
- #docbook-to-man debian/wavplayer.sgml > wavplayer.1
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- cat $$f > $${f%.in}; \
- sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
- sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
- done
-
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Add here commands to clean up after the build process.
- -$(MAKE) clean
- rm -rf CMakeCache.txt
- rm -rf CMakeFiles
- rm -rf cmake_install.cmake
- rm -rf Makefile
- rm -rf install_manifest.txt
-
- for f in `find $(CURDIR)/ -name "*.in"`; do \
- rm -f $${f%.in}; \
- done
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/wavplayer.
- $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
- mkdir -p $(CURDIR)/debian/tmp/opt/dbspace
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip --dbg-package=librua-dbg
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+ * RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __PERF_MEASURE__
+#define __PERF_MEASURE__
+
+#include <time.h>
+
+
+//#define PERF_MEASURE_ENABLE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef PERF_MEASURE_ENABLE
+
+unsigned int _perf_measure_start(const char *tag, char *func_name, int line);
+unsigned int _perf_measure_end(const char *tag, unsigned int ts_start,
+ char *func_name, int line);
+
+#define PERF_MEASURE_START(tag) _perf_measure_start(tag, __func__,__LINE__)
+#define PERF_MEASURE_END(tag, ts_start) \
+ _perf_measure_end(tag, ts_start,__func__, __LINE__)
+
+#else
+
+#define PERF_MEASURE_START(tag) (0)
+#define PERF_MEASURE_END(tag, ts_start) (0)
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__PERF_MEASURE__*/
--- /dev/null
+/*
+ * RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#include <stdio.h>
+#include <sys/time.h>
+
+unsigned int _perf_measure_start(const char *tag, char *func_name, int line)
+{
+ struct timeval t;
+ unsigned int ts_start;
+
+ if (!tag)
+ return 0;
+
+ gettimeofday(&t, NULL);
+ ts_start = t.tv_sec * 1000000UL + t.tv_usec;
+
+ printf("### START [%s:%d] timestamp(%u)\n", func_name, line, ts_start);
+
+ return ts_start;
+}
+
+unsigned int _perf_measure_end(const char *tag, unsigned int ts_start,
+ char *func_name, int line)
+{
+ struct timeval t;
+ unsigned int ts_end;
+ unsigned int elapsed_time = 0;
+
+ gettimeofday(&t, NULL);
+ ts_end = t.tv_sec * 1000000UL + t.tv_usec;
+
+ if (ts_start)
+ elapsed_time = ts_end - ts_start;
+
+ printf("### END [%s:%d] timestamp(%u)\n", func_name, line, ts_end);
+
+ if (elapsed_time)
+ printf("### ELAPSED [%s:%d] timestamp(%u)\n", func_name, line,
+ elapsed_time);
+
+ return ts_end;
+}
+
/*
* @file rua.c
- * @author Noha Park (noha.park@samsung.com)
* @version 0.1
*/
#include "rua.h"
#include "db-schema.h"
+#include "perf-measure.h"
#define RUA_DB_PATH "/opt/dbspace"
#define RUA_DB_NAME ".rua.db"
char query[QUERY_MAXLEN];
sqlite3_stmt *stmt;
+ unsigned int timestamp;
+ timestamp = PERF_MEASURE_START("RUA");
+
if (_db == NULL)
return -1;
return -1;
}
+ PERF_MEASURE_END("RUA", timestamp);
+
return r;
}
int rua_init(void)
{
+ unsigned int timestamp;
+ timestamp = PERF_MEASURE_START("RUA");
+
if (_db) {
return 0;
}
if (_db == NULL)
return -1;
+ PERF_MEASURE_END("RUA", timestamp);
+
return 0;
}
int rua_fini(void)
{
+ unsigned int timestamp;
+ timestamp = PERF_MEASURE_START("RUA");
+
if (_db) {
db_util_close(_db);
_db = NULL;
}
+ PERF_MEASURE_END("RUA", timestamp);
return 0;
}
--- /dev/null
+SET(RUATEST rua-test)
+SET(RUATEST_SRCS rua-test.c)
+SET(RUATEST_VENDOR samsung)
+SET(RUATEST_DIR /usr/bin)
+SET(RUATEST_LOCALEDIR /usr/share/locale)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+PKG_CHECK_MODULES(RUATEST_PKGS REQUIRED
+ )
+
+FOREACH(flag ${RUATEST_PKGS_CFLAGS})
+ SET(RUATEST_CFLAGS "${RUATEST_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(RUATEST_CFLAGS, "${RUATEST_CFLAGS} -DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+ADD_EXECUTABLE(${RUATEST} ${RUATEST_SRCS})
+SET_TARGET_PROPERTIES(${RUATEST} PROPERTIES COMPILE_FLAGS "${RUATEST_CFLAGS}")
+TARGET_LINK_LIBRARIES(${RUATEST} ${PROJECT_NAME} ${RUATEST_PKGS_LDFLAGS})
+
+INSTALL(TARGETS ${RUATEST} DESTINATION bin)
+
--- /dev/null
+/*
+ * RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <getopt.h>
+#include <time.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "rua.h"
+
+int __add_history(char *pkgname)
+{
+ int ret = 0;
+ struct rua_rec rec;
+ char apppath[FILENAME_MAX] = "";
+
+ snprintf(apppath, "/opt/apps/%s", pkgname, FILENAME_MAX);
+ memset(&rec, 0, sizeof(rec));
+ rec.pkg_name = pkgname;
+ rec.app_path = apppath;
+
+ ret = rua_init();
+ if (ret) {
+ fprintf(stderr, "error rua_init()\n");
+ return -1;
+ }
+
+ ret = rua_add_history(&rec);
+
+ rua_fini();
+
+ return ret;
+
+}
+
+int main(int argc, char* argv[])
+{
+ int ret = 0;
+
+ if (argc != 2)
+ return 0;
+ ret = __add_history(argv[1]);
+ return 0;
+}
+
+