From c1b1d4153e8f77508ffeb785b2e11df37f43fcef Mon Sep 17 00:00:00 2001 From: yubo Date: Fri, 15 May 2015 22:54:32 +0800 Subject: [PATCH 1/5] add benchmark --- rrd_test.go | 83 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 6 deletions(-) diff --git a/rrd_test.go b/rrd_test.go index 135ea71f9..eedd462d4 100644 --- a/rrd_test.go +++ b/rrd_test.go @@ -2,17 +2,27 @@ package rrdlite import ( "fmt" + "os" + "os/exec" "testing" "time" ) -func TestAll(t *testing.T) { +const ( + dbfile = "/tmp/test.rrd" + step = 1 + heartbeat = 2 * step + b_size = 100000 +) + +var now time.Time + +func init() { + now = time.Now() +} + +func testAll(t *testing.T) { // Create - const ( - dbfile = "/tmp/test.rrd" - step = 1 - heartbeat = 2 * step - ) c := NewCreator(dbfile, time.Now(), step) c.RRA("AVERAGE", 0.5, 1, 100) @@ -85,3 +95,64 @@ func TestAll(t *testing.T) { row++ } } + +func add(b *testing.B, filename string) { + c := NewCreator(filename, now, step) + c.RRA("AVERAGE", 0.5, 1, 100) + c.RRA("AVERAGE", 0.5, 5, 100) + c.DS("g", "GAUGE", heartbeat, 0, 60) + err := c.Create(true) + if err != nil { + b.Fatal(err) + } +} + +func update(b *testing.B, filename string) { + u := NewUpdater(filename) + err := u.Update(now, 1.5) + if err != nil { + b.Fatal(err) + } +} + +func BenchmarkAdd(b *testing.B) { + b.StopTimer() + if err := exec.Command("rm", "-rf", "/tmp/rrd").Run(); err != nil { + b.Fatal(err) + } + if err := os.Mkdir("/tmp/rrd", 0755); err != nil { + b.Fatal(err) + } + for i := 0; i < 256; i++ { + if err := os.Mkdir(fmt.Sprintf("/tmp/rrd/%d", i), 0755); err != nil { + b.Fatal(err) + } + } + b.StartTimer() + b.N = b_size + for i := 0; i < b.N; i++ { + filename := fmt.Sprintf("/tmp/rrd/%d/%d.rrd", i%256, i) + add(b, filename) + } +} + +func BenchmarkUpdate(b *testing.B) { + b.N = b_size + for i := 0; i < b.N; i++ { + filename := fmt.Sprintf("/tmp/rrd/%d/%d.rrd", i%256, i) + update(b, filename) + } + +} + +func BenchmarkFetch(b *testing.B) { + b.N = b_size + start := time.Unix(now.Unix()-step, 0) + end := start.Add(20 * step * time.Second) + for i := 0; i < b.N; i++ { + filename := fmt.Sprintf("/tmp/rrd/%d/%d.rrd", i%256, i) + if _, err := Fetch(filename, "AVERAGE", start, end, step*time.Second); err != nil { + b.Fatal(err) + } + } +} From 781706ae1159874ab9224dca6910df6ef27c2fbe Mon Sep 17 00:00:00 2001 From: yubo Date: Sun, 17 May 2015 15:27:47 +0800 Subject: [PATCH 2/5] change benchmark to multi-routine --- rrd_test.go | 65 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/rrd_test.go b/rrd_test.go index eedd462d4..0e6a84db0 100644 --- a/rrd_test.go +++ b/rrd_test.go @@ -4,6 +4,8 @@ import ( "fmt" "os" "os/exec" + "runtime" + "sync" "testing" "time" ) @@ -13,12 +15,15 @@ const ( step = 1 heartbeat = 2 * step b_size = 100000 + work_size = 10 ) var now time.Time +var wg sync.WaitGroup func init() { now = time.Now() + runtime.GOMAXPROCS(runtime.NumCPU()) } func testAll(t *testing.T) { @@ -115,6 +120,14 @@ func update(b *testing.B, filename string) { } } +func fetch(b *testing.B, filename string, start, end time.Time) { + if fetchRes, err := Fetch(filename, "AVERAGE", start, end, step*time.Second); err != nil { + b.Fatal(err) + } else { + fetchRes.FreeValues() + } +} + func BenchmarkAdd(b *testing.B) { b.StopTimer() if err := exec.Command("rm", "-rf", "/tmp/rrd").Run(); err != nil { @@ -130,29 +143,51 @@ func BenchmarkAdd(b *testing.B) { } b.StartTimer() b.N = b_size - for i := 0; i < b.N; i++ { - filename := fmt.Sprintf("/tmp/rrd/%d/%d.rrd", i%256, i) - add(b, filename) - } + n := b.N / work_size + for j := 0; j < work_size; j++ { + wg.Add(1) + go func(j int) { + defer wg.Done() + for i := 0; i < n; i++ { + filename := fmt.Sprintf("/tmp/rrd/%d/%d-%d.rrd", i%256, j, i) + add(b, filename) + } + }(j) + } + wg.Wait() } func BenchmarkUpdate(b *testing.B) { b.N = b_size - for i := 0; i < b.N; i++ { - filename := fmt.Sprintf("/tmp/rrd/%d/%d.rrd", i%256, i) - update(b, filename) - } - + n := b.N / work_size + + for j := 0; j < work_size; j++ { + wg.Add(1) + go func(j int) { + defer wg.Done() + for i := 0; i < n; i++ { + filename := fmt.Sprintf("/tmp/rrd/%d/%d-%d.rrd", i%256, j, i) + update(b, filename) + } + }(j) + } + wg.Wait() } func BenchmarkFetch(b *testing.B) { b.N = b_size + n := b.N / work_size start := time.Unix(now.Unix()-step, 0) end := start.Add(20 * step * time.Second) - for i := 0; i < b.N; i++ { - filename := fmt.Sprintf("/tmp/rrd/%d/%d.rrd", i%256, i) - if _, err := Fetch(filename, "AVERAGE", start, end, step*time.Second); err != nil { - b.Fatal(err) - } - } + for j := 0; j < work_size; j++ { + wg.Add(1) + go func(j int) { + defer wg.Done() + for i := 0; i < n; i++ { + filename := fmt.Sprintf("/tmp/rrd/%d/%d-%d.rrd", i%256, j, i) + fetch(b, filename, start, end) + } + }(j) + } + wg.Wait() } From 63e3daadd9bea5dae2a1c5461e6813292b772168 Mon Sep 17 00:00:00 2001 From: yubo Date: Tue, 27 Oct 2015 12:07:27 +0800 Subject: [PATCH 3/5] support os x --- gettext.h | 30 ----------------------- rrd_c.go | 3 ++- rrd_config.h | 68 +++++++++++++--------------------------------------- 3 files changed, 18 insertions(+), 83 deletions(-) diff --git a/gettext.h b/gettext.h index b9380cc9e..ea1042846 100644 --- a/gettext.h +++ b/gettext.h @@ -19,36 +19,6 @@ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 -/* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS - -/* Get declarations of GNU message catalog functions. */ -# include - -/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by - the gettext() and ngettext() macros. This is an alternative to calling - textdomain(), and is useful for libraries. */ -# ifdef DEFAULT_TEXT_DOMAIN -# undef gettext -# define gettext(Msgid) \ - dgettext (DEFAULT_TEXT_DOMAIN, Msgid) -# undef ngettext -# define ngettext(Msgid1, Msgid2, N) \ - dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) -# endif - -#else - -/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which - chokes if dcgettext is defined as a macro. So include it now, to make - later inclusions of a NOP. We don't include - as well because people using "gettext.h" will not include , - and also including would fail on SunOS 4, whereas - is OK. */ -#if defined(__sun) -# include -#endif - /* Many header files from the libstdc++ coming with g++ 3.3 or newer include , which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of a NOP. */ diff --git a/rrd_c.go b/rrd_c.go index 9569e4750..d53dd8680 100644 --- a/rrd_c.go +++ b/rrd_c.go @@ -4,7 +4,8 @@ package rrdlite #include #include "rrd.h" #include "rrdfunc.h" -#cgo CFLAGS: -std=c99 -DRRD_LITE -D_BSD_SOURCE -DHAVE_CONFIG_H -D_POSIX_SOURCE -DNUMVERS=1.4009 +#cgo linux CFLAGS: -std=c99 -DRRD_LITE -D_BSD_SOURCE -DHAVE_CONFIG_H -D_POSIX_SOURCE -DNUMVERS=1.4009 -D_LINUX_OS +#cgo darwin CFLAGS: -std=c99 -DRRD_LITE -D_BSD_SOURCE -DHAVE_CONFIG_H -D_POSIX_SOURCE -DNUMVERS=1.4009 -D_DARWIN_OS #cgo LDFLAGS: -lm */ import "C" diff --git a/rrd_config.h b/rrd_config.h index dcb18aaa6..cf59c4b7a 100644 --- a/rrd_config.h +++ b/rrd_config.h @@ -21,26 +21,30 @@ # endif #endif - +#if defined(_LINUX_OS) +#define HAVE_DECL_POSIX_FADVISE 1 +#define HAVE_FEATURES_H 1 +#define HAVE_POSIX_FADVISE 1 +#define HAVE_POSIX_FALLOCATE 1 +#define HAVE_MMAP 1 +#define HAVE_DECL_MADVISE 1 +#define HAVE_MADVISE 1 +#endif + +#if defined(_DARWIN_OS) +//#define HAVE_DECL_POSIX_FADVISE 0 +//#define HAVE_FEATURES_H 1 +//#define HAVE_POSIX_FADVISE 0 +//#define HAVE_POSIX_FALLOCATE 1 +#endif /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -#define ENABLE_NLS 1 /* set to 1 if msync with MS_ASYNC fails to update mtime */ /* #undef HAVE_BROKEN_MS_ASYNC */ -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -/* #undef HAVE_CFLOCALECOPYCURRENT */ - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ - /* Define to 1 if you have the `chdir' function. */ #define HAVE_CHDIR 1 @@ -53,17 +57,8 @@ /* Define to 1 if you have the header file. */ #define HAVE_CTYPE_H 1 -/* Define if the GNU dcgettext() function is already present or preinstalled. - */ -#define HAVE_DCGETTEXT 1 -/* Define to 1 if you have the declaration of `madvise', and to 0 if you - don't. */ -#define HAVE_DECL_MADVISE 1 -/* Define to 1 if you have the declaration of `posix_fadvise', and to 0 if you - don't. */ -#define HAVE_DECL_POSIX_FADVISE 1 /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you don't. */ @@ -88,9 +83,6 @@ /* Define to 1 if you have the `fdatasync' function. */ #define HAVE_FDATASYNC 1 -/* Define to 1 if you have the header file. */ -#define HAVE_FEATURES_H 1 - /* Define to 1 if you have the `finite' function. */ /* #undef HAVE_FINITE */ @@ -121,9 +113,6 @@ /* Define to 1 if you have the `getrusage' function. */ #define HAVE_GETRUSAGE 1 -/* Define if the GNU gettext() function is already present or preinstalled. */ -#define HAVE_GETTEXT 1 - /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 @@ -133,9 +122,6 @@ /* Define to 1 if you have the `hosts_access' function. */ /* #undef HAVE_HOSTS_ACCESS */ -/* Define if you have the iconv() function and it works. */ -/* #undef HAVE_ICONV */ - /* Define to 1 if you have the header file. */ /* #undef HAVE_IEEEFP_H */ @@ -163,9 +149,6 @@ /* Define to 1 if you have the header file. */ #define HAVE_LIBGEN_H 1 -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - /* have got libwrap installed */ /* #undef HAVE_LIBWRAP */ @@ -175,11 +158,6 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_LUA_H */ -/* Define to 1 if you have the `madvise' function. */ -#define HAVE_MADVISE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 /* Define to 1 if you have the header file. */ #define HAVE_MATH_H 1 @@ -196,8 +174,6 @@ /* Define to 1 if you have the `mktime' function. */ #define HAVE_MKTIME 1 -/* Define to 1 if you have the `mmap' function. */ -#define HAVE_MMAP 1 /* Define to 1 if you have the `msync' function. */ #define HAVE_MSYNC 1 @@ -214,12 +190,6 @@ /* Define to 1 if you have the `opendir' function. */ #define HAVE_OPENDIR 1 -/* Define to 1 if you have the `posix_fadvise' function. */ -#define HAVE_POSIX_FADVISE 1 - -/* Define to 1 if you have the `posix_fallocate' function. */ -#define HAVE_POSIX_FALLOCATE 1 - /* Define to 1 if you have the `posix_madvise' function. */ /* #undef HAVE_POSIX_MADVISE */ @@ -321,9 +291,6 @@ /* Define to 1 if you have the `vsnprintf' function. */ #define HAVE_VSNPRINTF 1 -/* Define to 1 if you have the `_NL_TIME_WEEK_1STDAY' function. */ -#define HAVE__NL_TIME_WEEK_1STDAY 1 - /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" @@ -362,9 +329,6 @@ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 -/* Define to 1 if strerror_r returns char *. */ -#define STRERROR_R_CHAR_P 1 - /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 From b7eac2f45dfdb19651ea846ec28e9ea130c077e9 Mon Sep 17 00:00:00 2001 From: yubo Date: Tue, 27 Oct 2015 12:19:17 +0800 Subject: [PATCH 4/5] remove gettext.h --- gettext.h | 241 ------------------------------------------------------ 1 file changed, 241 deletions(-) delete mode 100644 gettext.h diff --git a/gettext.h b/gettext.h deleted file mode 100644 index ea1042846..000000000 --- a/gettext.h +++ /dev/null @@ -1,241 +0,0 @@ -/* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _LIBGETTEXT_H -#define _LIBGETTEXT_H 1 - -/* Many header files from the libstdc++ coming with g++ 3.3 or newer include - , which chokes if dcgettext is defined as a macro. So include - it now, to make later inclusions of a NOP. */ -#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) -# include -# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H -# include -# endif -#endif - -/* Disabled NLS. - The casts to 'const char *' serve the purpose of producing warnings - for invalid uses of the value returned from these functions. - On pre-ANSI systems without 'const', the config.h file is supposed to - contain "#define const". */ -# define gettext(Msgid) ((const char *) (Msgid)) -# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) -# define dcgettext(Domainname, Msgid, Category) \ - ((void) (Category), dgettext (Domainname, Msgid)) -# define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 \ - ? ((void) (Msgid2), (const char *) (Msgid1)) \ - : ((void) (Msgid1), (const char *) (Msgid2))) -# define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) -# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N)) -# define textdomain(Domainname) ((const char *) (Domainname)) -# define bindtextdomain(Domainname, Dirname) \ - ((void) (Domainname), (const char *) (Dirname)) -# define bind_textdomain_codeset(Domainname, Codeset) \ - ((void) (Domainname), (const char *) (Codeset)) - -#endif - -/* A pseudo function call that serves as a marker for the automated - extraction of messages, but does not call gettext(). The run-time - translation is done at a different place in the code. - The argument, String, should be a literal string. Concatenated strings - and other string expressions won't work. - The macro's expansion is not parenthesized, so that it is suitable as - initializer for static 'char[]' or 'const char[]' variables. */ -#define gettext_noop(String) String - -/* The separator between msgctxt and msgid in a .mo file. */ -#define GETTEXT_CONTEXT_GLUE "\004" - -/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a - MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be - short and rarely need to change. - The letter 'p' stands for 'particular' or 'special'. */ -#ifdef DEFAULT_TEXT_DOMAIN -# define pgettext(Msgctxt, Msgid) \ - pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#else -# define pgettext(Msgctxt, Msgid) \ - pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#endif -#define dpgettext(Domainname, Msgctxt, Msgid) \ - pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ - pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) -#ifdef DEFAULT_TEXT_DOMAIN -# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#else -# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#endif -#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ - npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -pgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - int category) -{ - const char *translation = dcgettext (domain, msg_ctxt_id, category); - if (translation == msg_ctxt_id) - return msgid; - else - return translation; -} - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -npgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) -{ - const char *translation = - dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); - if (translation == msg_ctxt_id || translation == msgid_plural) - return (n == 1 ? msgid : msgid_plural); - else - return translation; -} - -/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID - can be arbitrary expressions. But for string literals these macros are - less efficient than those above. */ - -#include - -#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ - (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || __STDC_VERSION__ >= 199901L */ ) - -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS -#include -#endif - -#define pgettext_expr(Msgctxt, Msgid) \ - dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) -#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ - dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -dcpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - int category) -{ - size_t msgctxt_len = strlen (msgctxt) + 1; - size_t msgid_len = strlen (msgid) + 1; - const char *translation; -#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - char msg_ctxt_id[msgctxt_len + msgid_len]; -#else - char buf[1024]; - char *msg_ctxt_id = - (msgctxt_len + msgid_len <= sizeof (buf) - ? buf - : (char *) malloc (msgctxt_len + msgid_len)); - if (msg_ctxt_id != NULL) -#endif - { - memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); - msg_ctxt_id[msgctxt_len - 1] = '\004'; - memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dcgettext (domain, msg_ctxt_id, category); -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - if (msg_ctxt_id != buf) - free (msg_ctxt_id); -#endif - if (translation != msg_ctxt_id) - return translation; - } - return msgid; -} - -#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ - dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) -#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ - dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -dcnpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) -{ - size_t msgctxt_len = strlen (msgctxt) + 1; - size_t msgid_len = strlen (msgid) + 1; - const char *translation; -#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - char msg_ctxt_id[msgctxt_len + msgid_len]; -#else - char buf[1024]; - char *msg_ctxt_id = - (msgctxt_len + msgid_len <= sizeof (buf) - ? buf - : (char *) malloc (msgctxt_len + msgid_len)); - if (msg_ctxt_id != NULL) -#endif - { - memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); - msg_ctxt_id[msgctxt_len - 1] = '\004'; - memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - if (msg_ctxt_id != buf) - free (msg_ctxt_id); -#endif - if (!(translation == msg_ctxt_id || translation == msgid_plural)) - return translation; - } - return (n == 1 ? msgid : msgid_plural); -} - -#endif /* _LIBGETTEXT_H */ From f65db412e48d3816af2574144694b30eaaf065f5 Mon Sep 17 00:00:00 2001 From: yubo Date: Thu, 29 Oct 2015 11:26:09 +0800 Subject: [PATCH 5/5] enable go test --- rrd_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rrd_test.go b/rrd_test.go index 0e6a84db0..00fbbaf47 100644 --- a/rrd_test.go +++ b/rrd_test.go @@ -26,7 +26,7 @@ func init() { runtime.GOMAXPROCS(runtime.NumCPU()) } -func testAll(t *testing.T) { +func TestAll(t *testing.T) { // Create c := NewCreator(dbfile, time.Now(), step)