class PermissionResource(ModelResource): class Meta: queryset = auth_models.Permission.objects.all() object_model = queryset.model filtering = dict([(n,ALL_WITH_RELATIONS) for n in object_model._meta.get_all_field_names()]) resource_name = 'auth/permission' class UserResource(ModelResource): user_permissions = ToManyField(PermissionResource,'user_permissions',related_name='user_set',null=True) class Meta: queryset = auth_models.User.objects.all() object_model = queryset.model filtering = dict([(n,ALL_WITH_RELATIONS) for n in object_model._meta.get_all_field_names()]) resource_name = 'auth/user'
class PermissionResource(DjonyResource): class Meta: object_model = auth_models.Permission filtering = dict([(n,ALL_WITH_RELATIONS) for n in object_model._meta.get_all_field_names()]) resource_name = 'auth/permission' class UserResource(DjonyResource): user_permissions = SetField(PermissionResource,'user_permissions',related_name='user_set',null=True) class Meta: object_model = auth_models.User filtering = dict([(n,ALL_WITH_RELATIONS) for n in object_model._meta.get_all_field_names()]) resource_name = 'auth/user'
seva@SEVA (2):~/djony$ ab -n 100 -c 4 "http://localhost:8080/api/v2/auth/user/3/?format=json" This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient).....done Server Software: nginx/1.1.19 Server Hostname: localhost Server Port: 8080 Document Path: /api/v2/auth/user/3/?format=json Document Length: 5467 bytes Concurrency Level: 4 Time taken for tests: 17.331 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 582900 bytes HTML transferred: 546700 bytes Requests per second: 5.77 [#/sec] (mean) Time per request: 693.256 [ms] (mean) Time per request: 173.314 [ms] (mean, across all concurrent requests) Transfer rate: 32.84 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 1.5 0 9 Processing: 313 685 486.1 575 3357 Waiting: 312 684 485.8 574 3355 Total: 313 685 486.7 575 3357 Percentage of the requests served within a certain time (ms) 50% 575 66% 618 75% 647 80% 670 90% 819 95% 1320 98% 2797 99% 3357 100% 3357 (longest request) seva@SEVA (2):~/djony$ ab -n 100 -c 4 "http://localhost:8080/api/v3/auth/user/3/?format=json" This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient).....done Server Software: nginx/1.1.19 Server Hostname: localhost Server Port: 8080 Document Path: /api/v3/auth/user/3/?format=json Document Length: 5467 bytes Concurrency Level: 4 Time taken for tests: 8.339 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 582900 bytes HTML transferred: 546700 bytes Requests per second: 11.99 [#/sec] (mean) Time per request: 333.557 [ms] (mean) Time per request: 83.389 [ms] (mean, across all concurrent requests) Transfer rate: 68.26 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 137 317 375.9 243 2753 Waiting: 137 316 375.7 243 2751 Total: 137 317 375.9 243 2753 Percentage of the requests served within a certain time (ms) 50% 243 66% 264 75% 282 80% 299 90% 351 95% 433 98% 2670 99% 2753 100% 2753 (longest request)
seva@SEVA (2):~/djony$ ab -n 20 -c 4 "http://localhost:8080/api/v2/auth/user/?format=json&limit=0" This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient).....done Server Software: nginx/1.1.19 Server Hostname: localhost Server Port: 8080 Document Path: /api/v2/auth/user/?format=json&limit=0 Document Length: 306326 bytes Concurrency Level: 4 Time taken for tests: 40.891 seconds Complete requests: 20 Failed requests: 0 Write errors: 0 Total transferred: 6133760 bytes HTML transferred: 6126520 bytes Requests per second: 0.49 [#/sec] (mean) Time per request: 8178.157 [ms] (mean) Time per request: 2044.539 [ms] (mean, across all concurrent requests) Transfer rate: 146.49 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 0 Processing: 6235 7976 1035.4 7980 10671 Waiting: 6225 7959 1033.0 7958 10654 Total: 6235 7976 1035.4 7980 10671 Percentage of the requests served within a certain time (ms) 50% 7980 66% 8177 75% 8287 80% 8390 90% 10001 95% 10671 98% 10671 99% 10671 100% 10671 (longest request) seva@SEVA (2):~/djony$ ab -n 20 -c 4 "http://localhost:8080/api/v3/auth/user/?format=json&limit=0" This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient).....done Server Software: nginx/1.1.19 Server Hostname: localhost Server Port: 8080 Document Path: /api/v3/auth/user/?format=json&limit=0 Document Length: 306326 bytes Concurrency Level: 4 Time taken for tests: 11.841 seconds Complete requests: 20 Failed requests: 0 Write errors: 0 Total transferred: 6133760 bytes HTML transferred: 6126520 bytes Requests per second: 1.69 [#/sec] (mean) Time per request: 2368.136 [ms] (mean) Time per request: 592.034 [ms] (mean, across all concurrent requests) Transfer rate: 505.88 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 0 Processing: 1024 2269 806.2 2227 4492 Waiting: 1017 2252 803.6 2211 4472 Total: 1024 2269 806.2 2227 4492 Percentage of the requests served within a certain time (ms) 50% 2227 66% 2336 75% 2395 80% 2406 90% 4140 95% 4492 98% 4492 99% 4492 100% 4492 (longest request)
Source: https://habr.com/ru/post/201294/
All Articles