Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
d76eefa3
Commit
d76eefa3
authored
Aug 16, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bulk course threads query
parent
20a5fa91
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
17 deletions
+38
-17
config/benchmark.yml.sample
+6
-4
lib/tasks/benchmark.rake
+32
-13
No files found.
config/benchmark.yml.sample
View file @
d76eefa3
seed_size:
commentables: 20
users: 100
threads: 100
0
top_comments: 100
0
sub_comments: 200
0
votes: 1000
0
threads: 100
top_comments: 100
sub_comments: 200
votes: 1000
tags: 100
query_amount:
course_thread_query: 1000
lib/tasks/benchmark.rake
View file @
d76eefa3
require
'rest_client'
PREFIX
=
"http://localhost:4567/api/v1"
namespace
:benchmark
do
task
:bulk_generate
=>
:environment
do
seed_config
=
YAML
.
load_file
(
"config/benchmark.yml"
).
with_indifferent_access
COMMENTABLES
=
seed_config
[
:seed_size
][
:commentables
]
USERS
=
seed_config
[
:seed_size
][
:users
]
THREADS
=
seed_config
[
:seed_size
][
:threads
]
TOP_COMMENTS
=
seed_config
[
:seed_size
][
:top_comments
]
SUB_COMMENTS
=
seed_config
[
:seed_size
][
:sub_comments
]
VOTES
=
seed_config
[
:seed_size
][
:votes
]
TAGS
=
seed_config
[
:seed_size
][
:tags
]
seed_size_config
=
YAML
.
load_file
(
"config/benchmark.yml"
).
with_indifferent_access
[
:seed_size
]
PREFIX
=
"http://localhost:4567/api/v1"
COMMENTABLES
=
seed_size_config
[
:commentables
]
USERS
=
seed_size_config
[
:users
]
THREADS
=
seed_size_config
[
:threads
]
TOP_COMMENTS
=
seed_size_config
[
:top_comments
]
SUB_COMMENTS
=
seed_size_config
[
:sub_comments
]
VOTES
=
seed_size_config
[
:votes
]
TAGS
=
seed_size_config
[
:tags
]
Benchmark
.
bm
(
31
)
do
|
x
|
RestClient
.
get
"
#{
PREFIX
}
/clean"
x
.
report
"create users
via api
"
do
x
.
report
"create users"
do
(
1
..
USERS
).
each
do
|
user_id
|
data
=
{
id:
user_id
,
username:
"user
#{
user_id
}
"
,
email:
"user
#{
user_id
}
@test.com"
}
RestClient
.
post
"
#{
PREFIX
}
/users"
,
data
end
end
x
.
report
"create new threads
via api
"
do
x
.
report
"create new threads"
do
(
1
..
THREADS
).
each
do
|
t
|
data
=
{
title:
"Interesting question"
,
body:
"cool"
,
anonymous:
false
,
\
course_id:
"1"
,
user_id:
(
rand
(
USERS
)
+
1
).
to_s
,
\
...
...
@@ -39,7 +39,7 @@ namespace :benchmark do
comment_thread_ids
=
CommentThread
.
all
.
to_a
.
map
(
&
:id
)
x
.
report
(
"create top comments
via api
"
)
do
x
.
report
(
"create top comments"
)
do
TOP_COMMENTS
.
times
do
data
=
{
body:
"lalala"
,
anonymous:
false
,
course_id:
"1"
,
user_id:
(
rand
(
USERS
)
+
1
).
to_s
}
...
...
@@ -68,4 +68,23 @@ namespace :benchmark do
end
end
end
task
:bulk_query
=>
:environment
do
query_amount_config
=
YAML
.
load_file
(
"config/benchmark.yml"
).
with_indifferent_access
[
:query_amount
]
COURSE_THREAD_QUERY
=
query_amount_config
[
:course_thread_query
]
Benchmark
.
bm
(
31
)
do
|
x
|
sort_keys
=
%w[date activity votes comments]
sort_order
=
"desc"
x
.
report
(
"querying threads in a course"
)
do
COURSE_THREAD_QUERY
.
times
do
query_params
=
{
course_id:
"1"
,
sort_key:
sort_keys
.
sample
,
sort_order:
sort_order
,
page:
1
+
rand
(
100
),
per_page:
5
}
RestClient
.
get
"
#{
PREFIX
}
/threads"
,
params:
query_params
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment