none
Question on Efficiecy - Array, Hash Table or System Data table RRS feed

  • Question

  • Fellow Powersheller's,

    There are numerous ways to do the same thing although some approaches give better benfits further on in the script.

    I have done Arrays, hash Tables, and System Datatables.

    If one was just loading into the object/variable and then dumping, and not much more than that, is any of these more efficient?

    thanks

    MG


    • Edited by mg101 Tuesday, December 18, 2018 4:39 PM altered item
    Tuesday, December 18, 2018 4:38 PM

Answers

  • I would say it depends on what you are doing. Hash tables can be very efficient because the methods take advantage of the fact that keys must be unique. But only key, value pairs are allowed. Arrays can have more dimensions and don't require uniqueness. The hash table ContainsKey method is very efficient for determining if a key exists in the table, and is much faster than any method you could use for an array. Datatables rely on the .NET framework, where efficiency may depend on the version.

    Using Measure-Command to compare in a specific case would help.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by mg101 Tuesday, December 18, 2018 8:26 PM
    Tuesday, December 18, 2018 6:59 PM

All replies

  • Try measure-command on all of them.

    Tuesday, December 18, 2018 6:25 PM
  • I would say it depends on what you are doing. Hash tables can be very efficient because the methods take advantage of the fact that keys must be unique. But only key, value pairs are allowed. Arrays can have more dimensions and don't require uniqueness. The hash table ContainsKey method is very efficient for determining if a key exists in the table, and is much faster than any method you could use for an array. Datatables rely on the .NET framework, where efficiency may depend on the version.

    Using Measure-Command to compare in a specific case would help.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by mg101 Tuesday, December 18, 2018 8:26 PM
    Tuesday, December 18, 2018 6:59 PM
  • Thanks Richard
    Tuesday, December 18, 2018 8:26 PM
  • You are welcome.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, December 18, 2018 8:31 PM