evt-message_store-postgres-database 0.1.2.1 → 0.1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f60606ae8c240656ec9bfa46222eab384e54039ee6d3cc533a7994c5a87ea8d
4
- data.tar.gz: 5297a53575ce13ed914cf78323b11d7851a4b9c62519c5026311be2aadc82b1f
3
+ metadata.gz: 62245696a47206274440fad5630bf14635937d83df60edf818805213a59f177c
4
+ data.tar.gz: fc2d11f291a97d00f5958bf10955528f388bf700be64e63827108b8ba507ae49
5
5
  SHA512:
6
- metadata.gz: ce05880c9865bf71291c0b6b65ac90e83e58a7e03281f5fbd74c83feb617532ecc9785f948f1bda403dc8f0839683adea412d76eb026ad858d6f77f9895716ae
7
- data.tar.gz: ec5fdec6a130cdbfc5b270918a93211bcaac7bc09e01caff17a82d22ed8de9610a051bd9cf39b3c674c96014b2220499fdeca90f2730ce539ac9c8ec2c8b679f
6
+ metadata.gz: e707f37a458c5c3f0640bbdf698c07ab76d0e2f135b0ac4ac4b59b32e7b8b4259018342da70c6064e52c96dc3c85b7d65ebb47f7ff8dbc8731ff87144a4b65d7
7
+ data.tar.gz: e2c0a7d75b4514b29454e20863f3095bcad79703f6378972df6e78e5deabe6e365b29acd0fb1fc4463c8e6df0495109aa11278cbb622bd5dbf61cd6d9f55f8b3
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -u
4
+
5
+ uuid=$(echo $(uuidgen) | tr '[:upper:]' '[:lower:]')
6
+
7
+ stream_name="testStream-$uuid"
8
+ if [ ! -z ${STREAM_NAME+x} ]; then
9
+ stream_name=$STREAM_NAME
10
+ fi
11
+
12
+ cycles=1000
13
+ if [ ! -z ${CYCLES+x} ]; then
14
+ cycles=$CYCLES
15
+ fi
16
+
17
+ function script_dir {
18
+ val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
19
+ echo "$val"
20
+ }
21
+
22
+ base=$(script_dir)
23
+
24
+ echo
25
+ echo "Benchmark $cycles cycles (Stream Name: $stream_name)"
26
+ echo "= = ="
27
+ echo
28
+
29
+ default_name=message_store
30
+
31
+ if [ -z ${DATABASE_USER+x} ]; then
32
+ echo "(DATABASE_USER is not set)"
33
+ user=$default_name
34
+ else
35
+ user=$DATABASE_USER
36
+ fi
37
+ echo "Database user is: $user"
38
+
39
+ if [ -z ${DATABASE_NAME+x} ]; then
40
+ echo "(DATABASE_NAME is not set)"
41
+ database=$default_name
42
+ else
43
+ database=$DATABASE_NAME
44
+ fi
45
+ echo "Database name is: $database"
46
+ echo
47
+
48
+ echo "Installing benchmark scripts"
49
+ echo
50
+
51
+ psql $database -f $base/benchmark_write.sql
52
+ psql $database -f $base/benchmark_get.sql
53
+
54
+ echo
55
+ echo "Benchmarking write"
56
+ echo "- - -"
57
+ echo
58
+
59
+ psql $database -c "EXPLAIN ANALYZE SELECT benchmark_write('$stream_name'::varchar, $cycles::int);"
60
+
61
+ echo
62
+
63
+
64
+ echo
65
+ echo "Benchmarking get"
66
+ echo "- - -"
67
+ echo
68
+
69
+ psql $database -c "EXPLAIN ANALYZE SELECT benchmark_get('$stream_name'::varchar, $cycles::int);"
70
+
71
+ echo
@@ -0,0 +1,17 @@
1
+ CREATE OR REPLACE FUNCTION benchmark_get(
2
+ _stream_name varchar,
3
+ _cycles int DEFAULT 1000
4
+ )
5
+ RETURNS void
6
+ AS $$
7
+ BEGIN
8
+ FOR i IN 1.._cycles LOOP
9
+ -- RAISE NOTICE '%', i;
10
+ PERFORM * FROM get_stream_messages(_stream_name, _batch_size => 1);
11
+ END LOOP;
12
+ END;
13
+ $$ LANGUAGE plpgsql
14
+ VOLATILE;
15
+
16
+
17
+
@@ -0,0 +1,17 @@
1
+ CREATE OR REPLACE FUNCTION benchmark_write(
2
+ _stream_name varchar,
3
+ _cycles int DEFAULT 1000
4
+ )
5
+ RETURNS void
6
+ AS $$
7
+ BEGIN
8
+ FOR i IN 1.._cycles LOOP
9
+ -- RAISE NOTICE '%', i;
10
+ PERFORM write_message(gen_random_uuid()::varchar, _stream_name::varchar, 'SomeType'::varchar, '{"attribute": "some value"}'::jsonb, '{"metaAttribute": "some meta value"}'::jsonb);
11
+ END LOOP;
12
+ END;
13
+ $$ LANGUAGE plpgsql
14
+ VOLATILE;
15
+
16
+
17
+
@@ -17,10 +17,32 @@ echo "Writing $instances Messages to Stream $stream_name"
17
17
  echo "= = ="
18
18
  echo
19
19
 
20
+ default_name=message_store
21
+
22
+ if [ -z ${DATABASE_USER+x} ]; then
23
+ echo "(DATABASE_USER is not set)"
24
+ user=$default_name
25
+ else
26
+ user=$DATABASE_USER
27
+ fi
28
+ echo "Database user is: $user"
29
+
30
+ if [ -z ${DATABASE_NAME+x} ]; then
31
+ echo "(DATABASE_NAME is not set)"
32
+ database=$default_name
33
+ else
34
+ database=$DATABASE_NAME
35
+ fi
36
+ echo "Database name is: $database"
37
+ echo
38
+
39
+
20
40
  for (( i=1; i<=instances; i++ )); do
21
- uuid=$(uuidgen)
41
+ uuid=$(echo $(uuidgen) | tr '[:upper:]' '[:lower:]')
42
+
22
43
  echo "Instance: $i, Message ID: $uuid"
23
- psql message_store -c "SELECT write_message('$uuid'::varchar, '$stream_name'::varchar, 'SomeType'::varchar, '{\"attribute\": \"some value\"}'::jsonb, '{\"metaAttribute\": \"some meta value\"}'::jsonb);" > /dev/null
44
+
45
+ psql $database -c "SELECT write_message('$uuid'::varchar, '$stream_name'::varchar, 'SomeType'::varchar, '{\"attribute\": \"some value\"}'::jsonb, '{\"metaAttribute\": \"some meta value\"}'::jsonb);" > /dev/null
24
46
  done
25
47
 
26
48
  echo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-message_store-postgres-database
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.1
4
+ version: 0.1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: scripts
10
10
  cert_chain: []
11
- date: 2018-06-08 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " "
14
14
  email: opensource@eventide-project.org
@@ -22,6 +22,9 @@ executables:
22
22
  extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
+ - database/benchmark.sh
26
+ - database/benchmark_get.sql
27
+ - database/benchmark_write.sql
25
28
  - database/clear-events-table.sh
26
29
  - database/extensions.sql
27
30
  - database/functions/category.sql