Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
6b313132
Commit
6b313132
authored
9 years ago
by
Daniil Medvedev
Committed by
Konstantin Osipov
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gh-969 configurable tuple bench
parent
c36c989f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/box/tuple_bench.c
+35
-42
35 additions, 42 deletions
test/box/tuple_bench.c
test/box/tuple_bench.result
+11
-2
11 additions, 2 deletions
test/box/tuple_bench.result
test/box/tuple_bench.test.lua
+6
-2
6 additions, 2 deletions
test/box/tuple_bench.test.lua
with
52 additions
and
46 deletions
test/box/tuple_bench.c
+
35
−
42
View file @
6b313132
...
...
@@ -18,6 +18,7 @@ tuple_bench(box_function_ctx_t *ctx, const char *args, const char *args_end)
uint32_t
space_id
=
box_space_id_by_name
(
SPACE_NAME
,
strlen
(
SPACE_NAME
));
uint32_t
index_id
=
box_index_id_by_name
(
space_id
,
INDEX_NAME
,
strlen
(
INDEX_NAME
));
if
(
space_id
==
BOX_ID_NIL
||
index_id
==
BOX_ID_NIL
)
{
return
box_error_raise
(
ER_PROC_C
,
"Can't find index %s in space %s"
,
...
...
@@ -26,50 +27,42 @@ tuple_bench(box_function_ctx_t *ctx, const char *args, const char *args_end)
say_debug
(
"space_id = %u, index_id = %u"
,
space_id
,
index_id
);
char
tuple_buf
[
4
][
64
];
char
*
tuple_end
[
4
]
=
{
tuple_buf
[
0
],
tuple_buf
[
1
],
tuple_buf
[
2
],
tuple_buf
[
3
]};
if
(
1
)
{
tuple_end
[
0
]
=
mp_encode_array
(
tuple_end
[
0
],
2
);
tuple_end
[
0
]
=
mp_encode_uint
(
tuple_end
[
0
],
2
);
tuple_end
[
0
]
=
mp_encode_str
(
tuple_end
[
0
],
"bce"
,
strlen
(
"abb"
));
tuple_end
[
1
]
=
mp_encode_array
(
tuple_end
[
1
],
2
);
tuple_end
[
1
]
=
mp_encode_uint
(
tuple_end
[
1
],
2
);
tuple_end
[
1
]
=
mp_encode_str
(
tuple_end
[
1
],
"abb"
,
strlen
(
"abb"
));
tuple_end
[
2
]
=
mp_encode_array
(
tuple_end
[
2
],
2
);
tuple_end
[
2
]
=
mp_encode_uint
(
tuple_end
[
2
],
1
);
tuple_end
[
2
]
=
mp_encode_str
(
tuple_end
[
2
],
"abb"
,
strlen
(
"abb"
));
tuple_end
[
3
]
=
mp_encode_array
(
tuple_end
[
3
],
2
);
tuple_end
[
3
]
=
mp_encode_uint
(
tuple_end
[
3
],
3
);
tuple_end
[
3
]
=
mp_encode_str
(
tuple_end
[
3
],
"ccd"
,
strlen
(
"abb"
));
}
else
if
(
0
){
tuple_end
[
0
]
=
mp_encode_array
(
tuple_end
[
0
],
1
);
tuple_end
[
0
]
=
mp_encode_uint
(
tuple_end
[
0
],
2
);
tuple_end
[
1
]
=
mp_encode_array
(
tuple_end
[
1
],
1
);
tuple_end
[
1
]
=
mp_encode_uint
(
tuple_end
[
1
],
1
);
tuple_end
[
2
]
=
mp_encode_array
(
tuple_end
[
2
],
1
);
tuple_end
[
2
]
=
mp_encode_uint
(
tuple_end
[
2
],
1
);
tuple_end
[
3
]
=
mp_encode_array
(
tuple_end
[
3
],
1
);
tuple_end
[
3
]
=
mp_encode_uint
(
tuple_end
[
3
],
3
);
}
else
{
tuple_end
[
0
]
=
mp_encode_array
(
tuple_end
[
0
],
1
);
tuple_end
[
0
]
=
mp_encode_str
(
tuple_end
[
0
],
"bce"
,
strlen
(
"abb"
));
tuple_end
[
1
]
=
mp_encode_array
(
tuple_end
[
1
],
1
);
tuple_end
[
1
]
=
mp_encode_str
(
tuple_end
[
1
],
"abb"
,
strlen
(
"abb"
));
tuple_end
[
2
]
=
mp_encode_array
(
tuple_end
[
2
],
1
);
tuple_end
[
2
]
=
mp_encode_str
(
tuple_end
[
2
],
"abb"
,
strlen
(
"abb"
));
tuple_end
[
3
]
=
mp_encode_array
(
tuple_end
[
3
],
1
);
tuple_end
[
3
]
=
mp_encode_str
(
tuple_end
[
3
],
"ccd"
,
strlen
(
"abb"
));
char
*
tuple_end
[
4
]
=
{
tuple_buf
[
0
],
tuple_buf
[
1
],
tuple_buf
[
2
],
tuple_buf
[
3
]};
const
uint64_t
test_numbers
[
4
]
=
{
2
,
2
,
1
,
3
};
const
char
test_strings
[
4
][
4
]
=
{
"bce"
,
"abb"
,
"abb"
,
"ccd"
};
/* get key types from args, and build test tuples with according types*/
uint32_t
arg_count
=
mp_decode_array
(
&
args
);
if
(
arg_count
<
1
)
{
return
box_error_raise
(
ER_PROC_C
,
"%s"
,
"invalid argument count"
);
}
uint32_t
n
=
mp_decode_array
(
&
args
);
uint32_t
knum
=
0
,
kstr
=
0
;
for
(
uint32_t
k
=
0
;
k
<
4
;
k
++
)
{
const
char
*
field
=
args
;
tuple_end
[
k
]
=
mp_encode_array
(
tuple_end
[
k
],
n
);
for
(
uint32_t
i
=
0
;
i
<
n
;
i
++
,
field
+=
3
)
{
if
(
mp_decode_strl
(
&
field
)
!=
3
)
{
say_error
(
"Arguments must be
\"
STR
\"
or
\"
NUM
\"
"
);
return
-
1
;
}
if
(
memcmp
(
field
,
"NUM"
,
3
)
==
0
)
{
tuple_end
[
k
]
=
mp_encode_uint
(
tuple_end
[
k
],
test_numbers
[
knum
]);
knum
=
(
knum
+
1
)
%
4
;
}
else
if
(
memcmp
(
field
,
"STR"
,
3
)
==
0
)
{
tuple_end
[
k
]
=
mp_encode_str
(
tuple_end
[
k
],
test_strings
[
kstr
],
strlen
(
test_strings
[
kstr
]));
kstr
=
(
kstr
+
1
)
%
4
;
}
else
{
say_error
(
"Arguments must be
\"
STR
\"
or
\"
NUM
\"
"
);
return
-
1
;
}
}
}
//tuple_cmp = tuple_compare_with_key;
double
t
=
proctime
();
box_tuple_t
*
tuple
;
for
(
int
i
=
0
;
i
<
80000000
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
test/box/tuple_bench.result
+
11
−
2
View file @
6b313132
...
...
@@ -16,7 +16,10 @@ box.schema.user.grant('guest', 'execute', 'function', 'tuple_bench')
space = box.schema.space.create('tester')
---
...
_ = space:create_index('primary', {type = 'TREE', parts = {1, 'NUM', 2, 'STR'}})
key_parts = {1, 'NUM', 2, 'STR'}
---
...
_ = space:create_index('primary', {type = 'TREE', parts = key_parts})
---
...
box.schema.user.grant('guest', 'read,write', 'space', 'tester')
...
...
@@ -41,7 +44,13 @@ prof.start('tuple.prof')
---
- true
...
c:call('tuple_bench')
key_types = {}
---
...
for i = 1, #key_parts, 2 do table.insert(key_types, key_parts[i + 1]) end
---
...
c:call('tuple_bench', key_types)
---
- []
...
...
...
This diff is collapsed.
Click to expand it.
test/box/tuple_bench.test.lua
+
6
−
2
View file @
6b313132
...
...
@@ -7,7 +7,8 @@ c = net:new(os.getenv("LISTEN"))
box
.
schema
.
func
.
create
(
'tuple_bench'
,
{
language
=
"C"
})
box
.
schema
.
user
.
grant
(
'guest'
,
'execute'
,
'function'
,
'tuple_bench'
)
space
=
box
.
schema
.
space
.
create
(
'tester'
)
_
=
space
:
create_index
(
'primary'
,
{
type
=
'TREE'
,
parts
=
{
1
,
'NUM'
,
2
,
'STR'
}})
key_parts
=
{
1
,
'NUM'
,
2
,
'STR'
}
_
=
space
:
create_index
(
'primary'
,
{
type
=
'TREE'
,
parts
=
key_parts
})
box
.
schema
.
user
.
grant
(
'guest'
,
'read,write'
,
'space'
,
'tester'
)
box
.
space
.
tester
:
insert
({
1
,
"abc"
,
100
})
...
...
@@ -17,7 +18,10 @@ box.space.tester:insert({3, "ccd", 200})
prof
=
require
(
'gperftools.cpu'
)
prof
.
start
(
'tuple.prof'
)
c
:
call
(
'tuple_bench'
)
key_types
=
{}
for
i
=
1
,
#
key_parts
,
2
do
table.insert
(
key_types
,
key_parts
[
i
+
1
])
end
c
:
call
(
'tuple_bench'
,
key_types
)
prof
.
flush
()
prof
.
stop
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment