Raised This Month: $150 Target: $400
 37% 

Dynamic Objects and Properties - v.0.0.26 - [2017.03.22]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-22-2015 , 20:34   Dynamic Objects and Properties - v.0.0.26 - [2017.03.22]
Reply With Quote #1

Dynamic Wiki | Download | Examples

Dynamic allows developers to use truly dynamic data structures in SourcePawn.
This means you can define a Methodmap and use Dynamic to back it's member data at run-time.
All dynamic members are typed which allows automatic type conversion between base types.

You can then extend and inherit Dynamic Methodmaps to build complex namespaces.
Namespaces simplify the sharing of complex structures which third party plugins can easily access with a minimal amount of code.


Features
- Fully methodmap based to try and give an Object Orientated feel
- Inherit Dynamic to make your own simple methodmaps
- Easily name and retrieve dynamic objects between multiple plugins (no natives required)!!!!
- Supports String, int, float, bool, Handle, Vector and Dynamic types
- Automatic type conversion!!
- Static objects for Server and Player Settings
- Hook member changes
- Member iteration / looping
- Member sorting
- Load and Save flat configs
- Load and Save KeyValue configs


Dynamic Methodmaps
- Extend Dynamic to create your own Dynamic methodmaps
- A Class Builder to quickly generate basic Dynamic methodmaps
- You dont have to muck around with Dynamic Member Offsets to improve performance
- All of the same features that come with Dynamic Objects

Planned Changes
- Add serialisation support using mysql

Download (v0.0.26)
Example Use + Features
Example Class Use Example
Class Example
Class Builder
Include File
__________________

Last edited by Neuro Toxin; 03-21-2017 at 09:49.
Neuro Toxin is offline
xCoderx
Senior Member
Join Date: Sep 2013
Location: United Kingdom
Old 08-23-2015 , 07:03   Re: Dynamic Objects and Properties
Reply With Quote #2

Very cool, Will save me a lot of time instead of using natives all the time
__________________
If you like my work and want to help support me, Please consider a donation <3
xCoderx is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2015 , 23:38   Re: Dynamic Objects and Properties
Reply With Quote #3

I've done some profiling of the current version attached to the OP.

Here is the profiling code:

Spoiler
The outputs are below for 3 runs:

Code:
[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.003906 second(s)
Created 99000 dynamic member(s) in 1.492187 second(s)
Read 99000 dynamic member(s) in 0.527343 second(s)
Verified 99000 dynamic member(s) in 2.871093 second(s)
Updated 99000 dynamic member(s) in 0.542968 second(s)
Disposed 1000 dynamic object(s) in 0.011718 second(s)

[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.003906 second(s)
Created 99000 dynamic member(s) in 1.460937 second(s)
Read 99000 dynamic member(s) in 0.531250 second(s)
Verified 99000 dynamic member(s) in 2.839843 second(s)
Updated 99000 dynamic member(s) in 0.546875 second(s)
Disposed 1000 dynamic object(s) in 0.011718 second(s)

[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.000000 second(s)
Created 99000 dynamic member(s) in 1.492187 second(s)
Read 99000 dynamic member(s) in 0.527343 second(s)
Verified 99000 dynamic member(s) in 2.863281 second(s)
Updated 99000 dynamic member(s) in 0.546875 second(s)
Disposed 1000 dynamic object(s) in 0.011718 second(s)
__________________

Last edited by Neuro Toxin; 08-28-2015 at 04:14.
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2015 , 23:57   Re: Dynamic Objects and Properties
Reply With Quote #4

I've made a second version.

The main idea was to try and speed up Create/Update member operations.

The internal data for each object is one array, rather than 3 arrays (one for each type (int, float, string)).

The member name is also contained in the data, where as the first version has a lookup array that points to the members position in the data array (1 per type again).

Code:
[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.000000 second(s)
Created 99000 dynamic member(s) in 2.285156 second(s)
CRASHED FOR TAKING TO LONG LOL
The benchmarks are considerably slower in this version. I think this is because the lookups per type in the first version are not looping the whole member set on each request.

I also believe lots of the internal functions are passing around arguments that could be static.

Version 002 is attached to this post.

If anyone has any idea's or suggestions on how to go about making this as optimised as possible, I'm all ears!
Attached Files
File Type: zip dynamic-002.zip (16.7 KB, 39 views)
__________________

Last edited by Neuro Toxin; 08-28-2015 at 04:18.
Neuro Toxin is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 08-27-2015 , 23:00   Re: Dynamic Objects and Properties
Reply With Quote #5

Cool stuff
__________________
zipcore is online now
Headline
SourceMod Moderator
Join Date: Mar 2015
Location: San Diego, California
Old 08-28-2015 , 00:06   Re: Dynamic Objects and Properties
Reply With Quote #6

Quote:
Originally Posted by zipcore View Post
cool stuff
he is back boys
__________________
Headline is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-28-2015 , 00:12   Re: Dynamic Objects and Properties
Reply With Quote #7

Quickly. Get him before he leaves lol

Edit: on topic. I done another version which is heaps faster!
__________________

Last edited by Neuro Toxin; 08-28-2015 at 00:14.
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-28-2015 , 04:39   Re: Dynamic Objects and Properties
Reply With Quote #8

Version 003.

I'm using a Trie for member lookups and arrays for data storage. It's up to 10 times faster.

The Trie holds the offset for where the members data is held in the internal array.

Code:
[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.000000 second(s)
Created 99000 dynamic member(s) in 0.164062 second(s)
Read 99000 dynamic member(s) in 0.113281 second(s)
Verified 99000 dynamic member(s) in 0.277343 second(s)
Updated 99000 dynamic member(s) in 0.125000 second(s)
Disposed 1000 dynamic object(s) in 0.007812 second(s)

[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.000000 second(s)
Created 99000 dynamic member(s) in 0.164062 second(s)
Read 99000 dynamic member(s) in 0.109375 second(s)
Verified 99000 dynamic member(s) in 0.265625 second(s)
Updated 99000 dynamic member(s) in 0.128906 second(s)
Disposed 1000 dynamic object(s) in 0.007812 second(s)

[SM] Starting Benchmark Tests...
Created 1000 dynamic object(s) in 0.000000 second(s)
Created 99000 dynamic member(s) in 0.164062 second(s)
Read 99000 dynamic member(s) in 0.109375 second(s)
Verified 99000 dynamic member(s) in 0.273437 second(s)
Updated 99000 dynamic member(s) in 0.125000 second(s)
Disposed 1000 dynamic object(s) in 0.011718 second(s)
Attached Files
File Type: zip dynamic-003.zip (16.3 KB, 63 views)
__________________

Last edited by Neuro Toxin; 08-28-2015 at 04:40.
Neuro Toxin is offline
aeleos
Member
Join Date: Sep 2014
Old 09-03-2015 , 00:52   Re: Dynamic Objects and Properties
Reply With Quote #9

Wow thank you for this, this is exactly what I have been needing for my plugin. I am correct in saying it works just like any other data type in that I can have an array of them like
Code:
Dynamic object[32]
__________________
aeleos is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 09-03-2015 , 01:44   Re: Dynamic Objects and Properties
Reply With Quote #10

You sure can

Edit: remember to initialise them as per the first post
__________________

Last edited by Neuro Toxin; 09-03-2015 at 01:46.
Neuro Toxin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:42.


Powered by vBulletin®
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Theme made by Freecode