Search Results

Search found 3 results on 1 pages for 'user343547'.

Page 1/1 | 1 

  • In a bash script echo shell commands

    - by user343547
    In a bash script how do I echo all shell commands called and expand any variable names? For example, given the following line: ls $DIRNAME I would like the script to run the command and display the following ls /full/path/to/some/dir The purpose is to save a log of all shell commands called and their arguments. Perhaps there is a better way of generating such a a log?

    Read the article

  • Access cost of dynamically created objects with dynamically allocated members

    - by user343547
    I'm building an application which will have dynamic allocated objects of type A each with a dynamically allocated member (v) similar to the below class class A { int a; int b; int* v; }; where: The memory for v will be allocated in the constructor. v will be allocated once when an object of type A is created and will never need to be resized. The size of v will vary across all instances of A. The application will potentially have a huge number of such objects and mostly need to stream a large number of these objects through the CPU but only need to perform very simple computations on the members variables. Could having v dynamically allocated could mean that an instance of A and its member v are not located together in memory? What tools and techniques can be used to test if this fragmentation is a performance bottleneck? If such fragmentation is a performance issue, are there any techniques that could allow A and v to allocated in a continuous region of memory? Or are there any techniques to aid memory access such as pre-fetching scheme? for example get an object of type A operate on the other member variables whilst pre-fetching v. If the size of v or an acceptable maximum size could be known at compile time would replacing v with a fixed sized array like int v[max_length] lead to better performance? The target platforms are standard desktop machines with x86/AMD64 processors, Windows or Linux OSes and compiled using either GCC or MSVC compilers.

    Read the article

  • Create Generic Class Instance from Static Method in a Derived Class

    - by user343547
    I have a class in C# with a template and static method similar to class BClass<T> { public static BClass<T> Create() { return new BClass<T>(); } } From this I derive a class and specify a template parameter to the base class class DClass : BClass<int> { } A problem occurs when I try to use the static method to create an instance of D class Program { static void Main(string[] args) { DClass d = DClass.Create(); } } Gives a compiler error "Cannot implicitly convert type 'Test.BClass<int ' to 'Test.DClass'." Adding the below cast leads to a runtime casting exception. DClass d = (DClass)DClass.Create(); Is there any succint way to allow the static method to create instances of the derived class? Ideally I would like the equivalent of a c++ typedef and I don't want the below syntax (which does work). BClass<int> d = DClass.Create();

    Read the article

1