I'm caching the Func<object, object>'s in a dictionary. Just seems slower then doing a normal new up for the same # of iterations and I was under the impression its supposed to be just about the same performance. I realize my code has other overhead, of course, but still...
Seems like it might have something to do with the parameters. Right now the constructor for the test class is:
public Test(string str, int i, Color color)
and new'ing up 1M takes 475ms with my current code. By doing NOTHING but changing the constructor to just:
public Test(/*string str, int i, Color color*/)
it drops to 200ms. So I tried adding 1 param back and it jumps to 312ms. 2 params = 390ms.
So... every additional param is adding quite a bit of time .
Now, adding back the first param was +112ms, but the 2nd one was only an additional +78ms. I would expect adding back the first param would be expensive since it would now travel down the param code path where without params it skips all that. However, I expected adding the 2nd param would be much cheaper since its just adding another iteration to the param loop.
A standard new up with all 3 params for 1M iterations takes only 31ms.
I'm estimating that there is about 140ms of overhead built into my dynamic new up code, I'm just not getting why adding params is so expensive. So I tried one more test...
for (int i = 0; i < 1000000; i++)
int j = 5;
string s = "hello";
Color cr = Color.Red;
//int k = j;
//object k1 = j;
//object k2 = s;
object k3 = cr;
Seems like the boxing & type casting of the int and color is killing the performance. Boxing a string seems to be pretty cheap. The int and color are structs though...
The requirements are to create objects on the fly with any number of constructor arguments. Almost like DI, but with a different spin. The only way I thought of being able to do that is to create an object as an input parameter and pass the arguments to the constructor as array, array, array and type casting to the proper type (from ConstructorInfo and ParameterInfo). Hmm... I added support for making constructor params byref, but that didn't help. Also doesn't seem to make a big performance diff if I pass in classes.
Lets say I have a solution (A) or a project (A) which is working properly and its framework is 2.0.
And I have a seperate empty project(B) which is I set its framework to 3.5. When I add my working project(A) to that blank solution what will be my working project's solution? Is it going to be updated to 3.5 automatically from 2.0 to 3.5?
If not, changing project (B)'s(-where project (A) is already been added to project (B) ) framework manually from the solution's property window to 4.0 also changes project (A)'s framework as well(will .Net automatically change that project framework)?
Target framework is a project property and not solution property. It's possible that a solution has different projects with different target framework.
If you have a working project with specific framework and you do not mean to change/extend functionality - do not change target framework...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
I think certain kinds of "advice" without reference to the actual documentation is worthless (as in this case).
If one consults the actual documentation (help) re: "Data Contracts" it notes that:
"All .NET Framework primitive types, such as integers and strings, as well as certain types treated as primitives, such as DateTime and XmlElement, can be serialized with no other preparation and are considered as having default data contracts."
"New complex types that you create must have a data contract defined for them to be serializable."
I would say that your "Members" property is NOT a "primitive" type and therefore must have a "data contract".
(The SO example conveniently only shows primitive types).
and goes like that.
i need to calculate the time between first start and first idle time after the first start, then, time between second start and first idle after the second start, and it goes like that and there are too many lines. at the and i need total work time and total idle time.
Can anyone help me with this?
Last Visit: 31-Dec-99 19:00 Last Update: 29-Nov-22 17:57