Sign in to follow this  
Scrut

How i made a profiler by CHEATING

Recommended Posts

Scrut    88
Hello welcome to another one of my lovely threads. I will refrain from bad language, spelling\grammar(i will make some mistakes as i am so bad at this), and inappropriate language. I did not go crazy with the profiler, it works so biggidy bam! good to go!!! cmon lets do this seriously! Now to the Point! Please take me seriously and at least read the next part i want some feed back on my, nothing special, but simple profiler that works for everything i need atm.

First this is the cheat, and I say cheat because it cheats built in language security of classes protected\private functionality, that I used to make my profiler possable. The rest of my system is like ok; its another profiler what ever, but personally i did this because its used in a system where it MUST NOT KNOW the type it is contained in. Otherwise i would not go to the trouble, although for code reuse its fine. Ok here is how i let my profiler gain access to the profiler sample of any object in my engine\modules\game. Platform::u64 btw is a unsigned 64bit simple data type, declaration was encapsulated by Platform namespace(just posting my code exactly as it is sorry if its weird i ALWAYS do my own basic data types and never use data containers\interface\whatever directly but typedef my own types that i need to use them for end user\me\its just plain safer and looks cleaner plus the data type itself contains more information saying so much more why not)

#define SCRUT_PROFILERSAMPLE_INTERFACE_DECLARATION private: Scrut_ProfiledObject_AccessGrant m_sScrut_ProfiledObject_AccessGrant; public:

class CProfilerSample;

typedef ProfilerSample* ProfilerSamplePointer;
typedef std::list< ProfilerSamplePointer > ProfilerSampleList;
typedef ProfilerSampleList::iterator ProfilerSampleIterator;

struct Scrut_ProfiledObject_AccessGrant;

typedef Scrut_ProfiledObject_AccessGrant* Scrut_ProfiledObject_ProfilerSamplePointer;
typedef std::list< Scrut_ProfiledObject_AccessGrantPointer > Scrut_ProfiledObject_AccessGrantList;
typedef Scrut_ProfiledObject_AccessGrantList::iterator Scrut_ProfiledObject_AccessGrantIterator;

struct Scrut_ProfiledObject_AccessGrant {
Scrut_ProfiledObject_AccessGrantPointer m_pstParentObject;
Scrut_ProfiledObject_AccessGrantList m_tpstNestedObject;
ProfilerSampleList m_tpProfilerSampleTable;

Scrut_ProfilerSample_CreateList();
Scrut_ProfilerSample_DestroyList();

Scrut_ProfilerSample_Register( Platform::u64, ProfilerSamplePointer );
Scrut_ProfilerSample_Obtain( Platform::u64 );
};






Then inside the Scrut::System::CProfilerSample declaration i place SCRUT_PROFILERSAMPLE_INTERFACE_DECLARATION like so at the beginning. MUST BE AT BEGINNING so its does not run time error on ya. I assume the structure in memory will offset the memory address of say your object by 0. You can NEVER know the offset if this if it was after a section of data sense it does not know the objects its working with so they might just throw in another 32 bit variable and WAM addresses change. This should be very obvious sorry, this design is all soooooooo simple and i made it to be just 5 seconds of coding to get most reward in the end. AUTO_SIZE just declares and defines the implementation of functionality to take the size of your object, should be obvious but not needed for this class in particular just included for fullness and making everything uniform and its meant for a designed system, which i will not show you currently because i am writing up the past already, to be able to function and could not without it not going into it as u need not know my engine i am using at this current moment on such a lovely day. Again only included to keep what i have coded and what posted identical.


class CProfilerSample {
SCRUT_PROFILERSAMPLE_INTERFACE_DECLARATION
AUTO_SIZE






Do the same with every object in your program and u can profile every method of your implementation, sorry not included declarations so u can profiler functions. I wanted to get some feedback on the design in the way of how i made it able to work with objects that it cant know anything about as far as type identification. And i do not wanna make a uniform interface for all objects and do more polymorphism when i have a uniform object interface for all objects at another layer so i refuse(u cant make me wanna try!?!?!) make a uniform interface for a uniform interface.

Other part i will explain is really helpful on how it initializes at start of your methods\function. a Macro is used to declare a CProfilerSamplePointer and initialize its value. it just check if a method with that identifier for that particular Scrut::System::CProfilerSample is already on the parent's CProfilerSampleList within the Scrut::System::Scrut_ProfiledObject_AccessGrant structer if not it allocates one initializes it and pass it back, if it is in the list then it just passes back the current instance of that particular Scrut::System::CProfilerSample. also have a macro for the footer of your function at the very end of everything u wanna profile which when profiling functions and all that good stuff i pretty much leave this after every last line of code contain in that function.

and here is the rest of what i will go into now. just ask and ill explain the rest if you want but this i am explaining to much and sure this is prob just the opposite of elite so u do not need to tell me "hey this is not state of the art!" because yes i know i came up with this in 5 seconds and coded it in 5 seconds so its prob gimp. But here is the rest for now.

more macros exists, made it simplistic, for the purpose of being referenced and placed inside the objects constructor where it creates one Scrut::System::CProfilerSample for the object by default. You have one sample that has the information per object then the following samples in the std:list are place by the flow and order of there execution at run time so u then have statistics about whats this or that function did then u have the summations of all the data processed into one representation. but u must pass every object declared in that object too the macro system adding them to the Scrut::System::Scrut_ProfiledObject_AccessGrant::m_tpstNestedObject list and during this it just happens to also obviously u can guess it sets the Scrut::System::Scrut_ProfiledObject_AccessGrant::m_pstParentObject to the value of this sense this is done inside the parent objects constructor but not inside the children(nested objects), aka jumping execution(calling a function or procedure) and doing it a stupid way like passing the parent object's memory address or value of "this" as a argument to the subset. I built the tree so you can very easy without doing weird code watch the values during debug but also so i can make my life easier as i did not want to have this interact with my stream system which would let you not make the tree in memory at run time to print the values. This setup allows me to traverse the tree up and down where ever i need to go plus you need to know your parent so if you took x ms execution time with your current sample then you must update your parent with this new information so it actually works and not just useless functionality for no reason.

Ok well already spent more time writing this than i spent on the profiler WOW. Well anyways tell me what you guys think, and yes i expect well you should of done it this way your going to get this manifestation or error and your a noob. But hey all is well so here you go. Want any more info feel free to ask i will jump straight over to you and get you where you need to go as if you need help with a profiler(simplest things really so easy anyone can do it) i explain what ever i can also give you a version that excludes all the extra functionality so u can learn what your doing which actually i do not see happening as this stuff is really 100% straight beginner level.

[Edited by - Scrut on October 17, 2010 12:04:15 PM]

Share this post


Link to post
Share on other sites
Scrut    88
sorry wanted to be full. when it comes to passing values along making them able to interact with external systems and objects so for example u can PRINT them you can with, no thinking at all, so there must be more ways, use a simple stream or make ur own stream object what you want to call it, i believe there is a turoail on this site that uses a logger, but abstractly just go with the builder pattern i say(not sure if you see why but i like the builder pattern ever sense i learned it and i was using it all the time and din not know there was these name for this stuff)

Share this post


Link to post
Share on other sites
Antheus    2409
So...

class CProfilerSample : private Foo, public virtual Base, public virtual Bar, Baz {
SCRUT_PROFILERSAMPLE_INTERFACE_DECLARATION
AUTO_SIZE



So... At what offset is the profiling thingamajig now?

Share this post


Link to post
Share on other sites
Scrut    88
sorry but my design does not use any inheritance when i declared the class for your profiler samples. that actually is not how this is meant to be used so i will post later if you are serious(i hope your not because that would make me worry about your mental state) and help u out with your foobar or what ever u called it along with the rest design and what are you trying to do. it sounds like your asking me how c++(sorry i should of been explicit) objects when working with inheritance and less with the design of a profiler.... i mean are you serious because that just looks like a joke i am sorry but will not fuel any jokes as my last thread was serious and yet just non sense feedback(except for i think two post which i really enjoyed reading) but closed after it got going, and left the ground, and closed by moderator(he thought i was full of it)

Share this post


Link to post
Share on other sites
Scrut    88
also if you looked at the code u would of seen an error wouldnt compile i change the look of it and messed it up, i really do not know my audience so i will assume worst case scenario and u will take the littlest mistake as this is not worth our time.

Share this post


Link to post
Share on other sites
ChJees    141
I will be honest; You never got to the point of how you "cheated" to make a profiler.

I had a hard time understand what you were meaning in EVERY paragraph. No introduction or anything explaining how you achieved this feat.

Share this post


Link to post
Share on other sites
Scrut    88
o man i said something bad o man sorry so bad its just slipped out actually was not intentional and i hope i did not offend anyone. will be the last you ever see. sorry but im just ridin dirty and i am just Sippin' on some siz-erp, sip, sippin' on some, sip. what yall trippin bout, we straight thuggs.

Share this post


Link to post
Share on other sites
Scrut    88
from the feedback i will take it that this profiler is going to be put down in my book as another pass around the park and just plain practice. but hey thats not why i use it to make you happy so i am cool, a good father always loves his retarded baby, all thuggs know this, where you from?

Share this post


Link to post
Share on other sites
Scrut    88
on the cheating subject. no actual cheating, as it is supported without going around c++ and all the lovely details of the casting topic everyone learns when you start programming. Just need to be sure that the profiler information is structured in memory so that u gain access to all the profilers functionality from within your object's own methods. However like i said made in couple minutes that right when i actually THOUGHT about it right when i started the design like put my pen to paper and WAM thats right.... there is a better way to do it o well thats why i like feedback

Share this post


Link to post
Share on other sites
Scrut    88
um i posted a really bad word but changed it once i saw havent got a warning from it but if a moderator saw just look at how fast i changed it like no one saw so i hope i dodged a bullet.

Share this post


Link to post
Share on other sites
Scrut    88
and do u want me to actual spend some time writing up the design and use structure. I can write decent if i try, but you do not know me and one of those things about me is the fact that my grammer\spelling and my overall writing is to a level that language cannot describe how bad it is, just beyond limitations. But if you really want to understand it or want to hear more like i was saying i would love to help you out just do not expect this to be good design it is not quality why i use it but functionality for what i need atm really i dont need much just straight thuggish profiler. You can take the thugg out the street but you cant take the street out the thugg. And if she don't come home with it then shes sleeping over.

Ok not ganna make a new post for this as its no real new info on the subject but that i will have a post tomarrow after i wake up with all the designs explain in realy simple ways and ok i see now i am forced to used UML do not know why i did not as i am talking to a educated audience.

[Edited by - Scrut on October 18, 2010 12:33:11 AM]

Share this post


Link to post
Share on other sites
_the_phantom_    11250
ok, this stops NOW.

1) Stop bumping your own posts. If you have things to add to the posts after you make them (and others haven't posted) then use the edit button. This leads to...

2) Think about your posts before you make them. This is not an IM conversation, you don't have to bang out the posts quickly and come back and post another, and another and another.

3) We don't care about 'thugg' related things. Leave that at the door. Future references will result in your posts being closed. Repeated offenses will result in a suspension.

This isn't a request.

Share this post


Link to post
Share on other sites
Antheus    2409
Quote:
Original post by OrangyTang
Even as a native english speaker, I genuinely have absolutely no idea what you just said.


It reads almost like Joyce's Finnegans Wake, just with more thuggs.

Share this post


Link to post
Share on other sites
Scrut    88
ok i did this up in 3 seconds and this design is so fast to code and its less overhead mainly around the follow methods, its the functionality used when using the lists is what it boils down to


Scrut_ProfilerSample_Register( Platform::u64, ProfilerSamplePointer );
Scrut_ProfilerSample_Obtain( Platform::u64 );









but here this should tell you alot about what i changed

struct Scrut_ProfilerObject_SampleTableContainer;

typedef Scrut_ProfilerObject_SampleTableContainer* Scrut_ProfilerObject_SampleTableContainerPointer;
typedef std::list< Scrut_ProfilerObject_SampleTableContainerPointer > Scrut_ProfilerObject_SampleTableContainerList;
typedef Scrut_ProfilerObject_SampleTableContainerList::iterator Scrut_ProfilerObject_SampleTableContainerIterator;

struct Scrut_ProfiledObject_AccessGrant;

typedef Scrut_ProfiledObject_AccessGrant* Scrut_ProfiledObject_ProfilerSamplePointer;
typedef std::list< Scrut_ProfiledObject_AccessGrantPointer > Scrut_ProfiledObject_AccessGrantList;
typedef Scrut_ProfiledObject_AccessGrantList::iterator Scrut_ProfiledObject_AccessGrantIterator;

class Scrut_ProfilerObject_SampleTableContainer {
Scrut_ProfiledObject_ProfilerSamplePointer m_pstParentAccessGrant;
ProfilerSampleList m_tpProfilerSampleTable;

Scrut_ProfilerSample_CreateList( Scrut_ProfiledObject_ProfilerSamplePointer );
Scrut_ProfilerSample_DestroyList();

Scrut_ProfilerSample_Register( Platform::u64, ProfilerSamplePointer );
Scrut_ProfilerSample_Obtain( Platform::u64 );
};

struct Scrut_ProfilerObject_AssessGrant {
Scrut_ProfiledObject_AccessGrantPointer m_pstParentObject;
Scrut_ProfilerObject_SampleTableContainerPointer m_pstNestedObject;
Scrut_ProfilerObject_SampleTableContainerPointer m_pstProfilerSample;

Scrut_ProfilerSample_CreateList();
Scrut_ProfilerSample_DestroyList();

Scrut_ProfilerSample_Register( Platform::u64, ProfilerSamplePointer );
Scrut_ProfilerSample_Obtain( Platform::u64 );
};








had to change the code a bit after i coded it but what is above changed

WOW OK FOUND OUT ALONG TIME AGO LIKE WHAT WAS I THINKING with inheritence i dont have to use structs and casting o man god is prob crying atm with that one its so just why didnt i see it ive made them so many times the correct way this way works but the way i like sorry for wasting your time

its not cheating actually its perfectly legal and actually makes perfect sense just i view it as strange code at first the way i redesigned it clears everything up it was garbage thats why i said i programmed it in minutes

[Edited by - Scrut on October 17, 2010 3:16:23 PM]

Share this post


Link to post
Share on other sites
Scrut    88
my alternate way of making a profilerhere is just something i just made real fast i really didnt feel like doing real uml model but just made this in paint real fast it shows the structer of the profiler when i finished it im trying not to post to much so i dont want to post alot of code when i sent alot of nonsense sorry guys.
I know this is a really simple stupid profiler just wanted any opinions but now its designed so u can if you wanted say have add a IProfilerSample then u can if you wanted have one that can contain all your values as doubles or float then if i used a stream and made a logger i could then pass different values depending on what implimintation you used im not heading that dirrection because of how i wanted to use it with my gui and tools i already designed. so it doesnt care how you store your CProfilerSamples data and also what you analyze and what statistics you calculate. just saying now its designed in a way that it could do those things if you wanted but its more to my liking than what i started thread with.
also i left some arrows out to be assumed a NULL values

Share this post


Link to post
Share on other sites
Steve132    433
I'm going to be constructive.

What you are doing is actually a relatively interesting and complex attempt at accomplishing a common goal. You have done so in a way that I have never seen before. It is clear that you are attempting to be helpful and that you have paid attention do some design considerations. I applaud you for that.

The problem here is that, literally, due to your language (as in, your inability to communicate, not your swearing), no one can understand you. Much like C++, the English language has a grammar and rules, and if you expect to be understood, you must follow them.

If you are capable of writing compilable code in any language, then that shows that your pattern recognition neurons in your brain are functional enough to construct and recognize passable English. Therefore, your inability to do so is NOT justifiable for any reason, and it makes you seem lazy that you simply refuse speak properly. THAT is why you are being rated down, not because no-one likes you or your code. If you don't care about our ability to understand you, why should WE care about our ability to understand you?

Who you are and where you are from is irrelevent. If you want people to take you seriously and treat you like a professional, you need to act like a professional.

Share this post


Link to post
Share on other sites
iMalc    2466
A few facts about English that you don't appear to be aware of:

Every sentence begins with a capital letter.
Every sentence ends with a fullstop, period, dot, or whatever you call it in your part of the world, or some other mark such as an exclamation mark or question mark etc.
The word "I" is always capital no matter where in a sentence it appears; no exceptions.
"u" is not a word! An appropriate place to make up words would be in a fictional book. Do you really want anyone to take you seriously, or is all this merely a work of fiction?

Steve132's post sums it up nicely too.

Share this post


Link to post
Share on other sites
Scrut    88
here is a little more drawing in paint hope you see how i planned for this one to be used and also this is not my real design for my profiler now just kindof playing with this configuration

[massive inline image removed by jpetrie]

I did not mean to put the object list factories on system layer, as they do not go there. o well for i forgot entire systems, but the is the worst part of it is that i forgot to include alot of the connections and left out polymorphism related connections which is the reason i wanted to make it.

[Edited by - jpetrie on October 23, 2010 9:07:21 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this