Raised This Month: $51 Target: $400
 12% 

[ANY] SMObjects


Post New Thread Reply   
 
Thread Tools Display Modes
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-27-2017 , 17:02   Re: [ANY] SMObjects
Reply With Quote #11

It could be that SMObject uses the STL where StringMap uses sm_stringhashmap which uses ke::HashMap
__________________
WildCard65 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-27-2017 , 17:08   Re: [ANY] SMObjects
Reply With Quote #12

Benchmarking object creation, GetInt, SetInt into one benchmark time doesnt accuratly compair this extension to Dynamic.

Dynamic is a dymically typed collection with automatic type conversion and would spend most of its extra time creating objects.

Also note Dynamic has offsets which speedup the getters and setters dramaticly.

Using the class builder gives an example of this.

Edit: There is a dynamic-test plugin in the Dynamic package. Run this to get a proper benchmark with a high percision timer broken down into internal functions.
__________________

Last edited by Neuro Toxin; 06-27-2017 at 17:17.
Neuro Toxin is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-28-2017 , 05:33   Re: [ANY] SMObjects
Reply With Quote #13

Quote:
Originally Posted by WildCard65 View Post
It could be that SMObject uses the STL where StringMap uses sm_stringhashmap which uses ke::HashMap
I think it was just that SMObjects was doing too many lookups in the older version. There were always at least too full lookup operations taking place for every object write.
Now I've limited it to just one lookup

This looks much better. We're getting close, but StringMap is still slightly faster.

View both profilers here
Code:
[SMOBJECTS] Object creation took 0.002454 seconds
[SMOBJECTS] Object writing took 0.013774 seconds
[SMOBJECTS] Object reading took 0.004659 seconds
[SMOBJECTS] Object deletion took 0.007978 seconds
[SM] Plugin SMObjects-Profiler.smx reloaded successfully.

[StringMap] Object creation took 0.004738 seconds
[StringMap] Object writing took 0.011586 seconds
[StringMap] Object reading took 0.003434 seconds
[StringMap] Object deletion took 0.005322 seconds
[SM] Loaded plugin StringMap-Profiler.smx successfully.

[DYNAMIC] Object creation took 0.022605 seconds
[DYNAMIC] Object writing took 0.189613 seconds
[DYNAMIC] Object reading took 0.031048 seconds
[DYNAMIC] Object deletion took 0.038578 seconds
[SM] Plugin Dynamic-Profiler.smx reloaded successfully.

[KeyValues] Object creation took 0.006072 seconds
[KeyValues] Object writing took 0.016962 seconds
[KeyValues] Object reading took 0.006804 seconds
[KeyValues] Object deletion took 0.005861 seconds
[SM] Loaded plugin KeyValues-Profiler.smx successfully.
Quote:
Originally Posted by Neuro Toxin View Post
Benchmarking object creation, GetInt, SetInt into one benchmark time doesnt accuratly compair this extension to Dynamic.

Dynamic is a dymically typed collection with automatic type conversion and would spend most of its extra time creating objects.

Also note Dynamic has offsets which speedup the getters and setters dramaticly.
If you really want to you're more than welcome to write a dynamic profiler based off of these operations, but I'm more concerned with StringMaps tbh

EDIT: Fuck it I did it anyway. Scroll up.

Last edited by headline; 07-02-2017 at 19:54.
headline is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 07-24-2017 , 22:48   Re: [ANY] SMObjects
Reply With Quote #14

Is it possible to iterate an object for its members with this extension?
Otherwise, this is very neat and I'm glad someone has done it!

Do you have any plans to add de/serialization of keyvalue files from/into objects?
__________________
retired
shavit is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-25-2017 , 00:30   Re: [ANY] SMObjects
Reply With Quote #15

Quote:
Originally Posted by shavit View Post
Is it possible to iterate an object for its members with this extension?
Otherwise, this is very neat and I'm glad someone has done it!

Do you have any plans to add de/serialization of keyvalue files from/into objects?
These ideas are possible. I toyed with the idea of allowing iteration, but I am currently unsure exactly how I'd like for it to be implemented. Do you have any ideas?
headline is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-25-2017 , 01:00   Re: [ANY] SMObjects
Reply With Quote #16

Quote:
Originally Posted by Headline View Post
These ideas are possible. I toyed with the idea of allowing iteration, but I am currently unsure exactly how I'd like for it to be implemented. Do you have any ideas?
This might help.

https://github.com/ntoxin66/Dynamic/...rating-Members
__________________
Neuro Toxin is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-25-2017 , 01:11   Re: [ANY] SMObjects
Reply With Quote #17

Quote:
Originally Posted by Neuro Toxin View Post
This wraps std::map, and requires an actual iterator. Can't just index members like that.

Idk if I'd want to implement an iterator type, either. :/

Last edited by headline; 07-25-2017 at 01:14.
headline is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 07-25-2017 , 01:56   Re: [ANY] SMObjects
Reply With Quote #18

Quote:
Originally Posted by Headline View Post
These ideas are possible. I toyed with the idea of allowing iteration, but I am currently unsure exactly how I'd like for it to be implemented. Do you have any ideas?
Not really.. I'm not very experienced with C++.

But.. I guess you could assign an ID for every object member, add a .MemberCount (or a similar name) member and then allow members to be accessed by member IDs. That'll also need .MemberType that'll return things like Type_Integer, Type_Float etc.
__________________
retired
shavit is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-25-2017 , 18:10   Re: [ANY] SMObjects
Reply With Quote #19

Quote:
Originally Posted by shavit View Post
Not really.. I'm not very experienced with C++.

But.. I guess you could assign an ID for every object member, add a .MemberCount (or a similar name) member and then allow members to be accessed by member IDs. That'll also need .MemberType that'll return things like Type_Integer, Type_Float etc.
I just finished it (yay)

Here's what it'll look like.

Make sure you're using 1.0.1-git87 from the downloads page and don't forget to update your includes. I'll write up more docs later, but usage is pretty self explanatory. Let me know if you have issues
PHP Code:
// this code prints every single key and it's value, actual usage depends on what you wanna do
for (int i 0obj.MemberCounti++)
{
    
char key[32];
    
obj.GetMemberKey(ikeysizeof(key));
    
    
ObjectType type obj.GetMemberType(i);
    
    switch (
type)
    {
        case 
Type_Integer:
            
PrintToServer("\"%s\": %i"keyobj.GetMemberInt(i));
        case 
Type_Boolean:
            
PrintToServer("\"%s\": %i"keyobj.GetMemberBool(i));
        case 
Type_Float:
            
PrintToServer("\"%s\": %.2f"keyobj.GetMemberFloat(i));
        case 
Type_String:
        {
            
char value[128];
            
obj.GetMemberString(ivaluesizeof(value));
            
PrintToServer("\"%s\": %s"keyvalue);
        }
        case 
Type_CellArray:
        {
            
int size obj.GetMemberArraySize(i);
            
any[] array = new any[size];
            
obj.GetMemberArray(i, array, size);
            
PrintToServer("\"%s\": %s"key, array);
        }

    }


Last edited by headline; 07-25-2017 at 18:12.
headline is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-25-2017 , 18:39   Re: [ANY] SMObjects
Reply With Quote #20

Now that you can iterate, you have the bones for a write key values function.
__________________
Neuro Toxin is offline
Reply



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 01:52.


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