Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Timings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4604] Timings
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Wed, 21 Aug 1996 03:25:23 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Here are some timings for methods given in recent postings
Reordering lists and How do I use Select[list,condition]?

lst = {2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 3, 1, 1, 2, 1, 2, 1,
2, 1, 1,1, 1, 2, 1, 2, 1, 3, 1, 2, 2, 1, 2, 1, 2, 3, 2, 4, 1, 1, 1,  
1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1,
2,3, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1};

Do[lst/.{1->4,2->3,3->2,4->1},{100}]//Timing
Do[5 - lst,{100}]//Timing
Do[Switch[#,1,4,2,3,3,2,4,1]&/@lst,{100}]//Timing
Do[Map[Mod[#, 4] + 1&, lst],{100}]//Timing

{0.316667 Second, Null}
{2.85 Second, Null}
{2.9 Second, Null}
{3.35 Second, Null}


data = {{1,1,a,4,5,6},{2,1,a,2,3,4},{3,1,a,7,8,9},
               {1,2,b,4,5,6},{2,2,b,2,3,4},{3,2,b,7,8,9},
               {1,3,c,4,5,6},{2,3,c,2,3,4},{3,3,c,7,8,9}};

Do[Cases[data,{_,2,___}],{500}]//Timing
Do[Select[data,#[[2]]==2&],{500}]//Timing
Do[Select[data, MatchQ[#, {_,2,___}]&],{500}]//Timing

{0.716667 Second, Null}
{1.58333 Second, Null}
{2.25 Second, Null}

Allan Hayes
hay at haystack.demon.co.uk

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Help--which platform to purchase Mathematica for?
  • Next by Date: "Optimized" Plane
  • Previous by thread: Help: Mathematica in Win 95 without Network
  • Next by thread: "Optimized" Plane