Skip to main content
  1. Blog/

Speeding up ai-assisted content generation with nushell par-each

·1399 words·7 mins

Given this json list of wrestlers

[
  "Hulk Hogan",
  "Stone Cold Steve Austin",
  "The Rock",
  "Ric Flair",
  "Andre the Giant",
  "Shawn Michaels",
  "John Cena",
  "The Undertaker",
  "Bret Hart",
  "Macho Man Randy Savage"
]

the goal was simple.

Create a brief description of each wrestler.

In nushell that can be done in various ways. Two of which are:

from json | par-each --threads 10 { aichat short description of $in }

and

from json | each { aichat short description of $in }

The first one will make parallel requests to the openAI api.

The second one will make the requests one by one in serial.

The first one is about 8 times faster than the second one in this experiment.

4sec 125ms 25µs 958ns for the first one, 30sec 983ms 614µs 878ns for the second.

This is a significant difference. Though, both are much faster than probably any human.

For anyone wondering about the wrestlers, these are the results:

    ╭───┬─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ 0 │ Hulk Hogan, born Terry Eugene Bollea on August 11, 1953, is a retired professional wrestler, actor, and │
    │   │  television personality. He gained worldwide fame in the 1980s and 1990s as one of the biggest stars in │
    │   │  wrestling, particularly with World Wrestling Federation (WWF, now WWE). Known for his charisma, iconic │
    │   │  handlebar mustache, and catchphrases like "Hulkamania" and "Whatcha gonna do?", Hogan became a pop     │
    │   │ culture phenomenon. He has held multiple world championships and headlined several major wrestling      │
    │   │ events. Outside wrestling, he has appeared in films, TV shows, and commercials. Despite his success,    │
    │   │ Hogan's career has also faced controversies and legal battles.                                          │
    │ 1 │ "Stone Cold" Steve Austin, whose real name is Steve Austin, is a retired professional wrestler and one  │
    │   │ of the most iconic figures in the history of World Wrestling Entertainment (WWE). Known for his         │
    │   │ rebellious persona, Austin rose to stardom during the "Attitude Era" of the late 1990s and early 2000s. │
    │   │  He was instrumental in the WWE's battle against rival promotions, contributing to the company's        │
    │   │ dominance in the industry. Characterized by his anti-authority stance, signature catchphrases like      │
    │   │ "Austin 3:16" and "Can I get a Hell Yeah?", and his finishing move, the Stone Cold Stunner, Austin's    │
    │   │ legacy is celebrated for its impact on wrestling culture and pop culture at large.                      │
    │ 2 │ Dwayne "The Rock" Johnson is an American actor, producer, and former professional wrestler. Born on May │
    │   │  2, 1972, he gained fame in the wrestling world with the WWE, where he became one of the most popular   │
    │   │ and charismatic wrestlers. Known for his catchphrases and electrifying persona, The Rock transitioned   │
    │   │ to a successful acting career. He has starred in blockbuster movies such as the "Fast & Furious"        │
    │   │ franchise, "Jumanji," and "Moana." Johnson is recognized for his impressive physique, charismatic       │
    │   │ personality, and work ethic, making him a beloved figure in entertainment and pop culture.              │
    │ 3 │ Ric Flair, also known as "The Nature Boy," is a retired professional wrestler and wrestling manager,    │
    │   │ born on February 25, 1949. With a career spanning over 40 years, Flair is widely regarded as one of the │
    │   │  greatest professional wrestlers of all time. He is celebrated for his charismatic personality,         │
    │   │ flamboyant style, and significant contributions to the wrestling industry. Flair is a 16-time World     │
    │   │ Champion, an honor recognized by both WWE and WCW. His influence extends beyond the ring, making him a  │
    │   │ cultural icon and a key figure in the evolution of professional wrestling.                              │
    │ 4 │ André the Giant, born André René Roussimoff, was a French professional wrestler and actor renowned for  │
    │   │ his immense size, standing at 7 feet 4 inches and weighing approximately 520 pounds. His extraordinary  │
    │   │ stature was due to acromegaly, a condition caused by excess growth hormone. A beloved figure in World   │
    │   │ Wrestling Federation (WWF) during the 1970s and 80s, he was known for his larger-than-life personality  │
    │   │ and remarkable strength. Outside the ring, he achieved fame for his role as Fezzik in the cult classic  │
    │   │ film "The Princess Bride". André's legacy endures in both wrestling and popular culture, remembered for │
    │   │  his gentle demeanor and towering presence. He passed away in 1993.                                     │
    │ 5 │ Shawn Michaels, born Michael Shawn Hickenbottom on July 22, 1965, is a retired American professional    │
    │   │ wrestler, widely regarded as one of the greatest in the history of the sport. Known by the nickname     │
    │   │ "The Heartbreak Kid" (HBK), Michaels is celebrated for his charisma, in-ring agility, and ability to    │
    │   │ deliver memorable matches. His storied career in the WWE includes multiple WWE Championship reigns,     │
    │   │ unforgettable rivalries, and iconic matches such as the first-ever Hell in a Cell and the inaugural     │
    │   │ Ladder Match. Inducted into the WWE Hall of Fame in 2011, his legacy continues to influence the         │
    │   │ wrestling world today.                                                                                  │
    │ 6 │ John Cena is an American professional wrestler, actor, and television host, known for his tenure with   │
    │   │ WWE (World Wrestling Entertainment). Born on April 23, 1977, he has won multiple world championships    │
    │   │ and is prominently known for his "Never Give Up" mantra. Outside of wrestling, Cena has appeared in     │
    │   │ various films such as "Blockers" and "The Suicide Squad," and he has also hosted shows like "Are You    │
    │   │ Smarter Than a 5th Grader?" He is recognized for his philanthropy, especially with the Make-A-Wish      │
    │   │ Foundation, where he holds the record for granting the most wishes.                                     │
    │ 7 │ The Undertaker, whose real name is Mark William Calaway, is a retired American professional wrestler    │
    │   │ widely regarded as one of the greatest in WWE history. Debuting in 1990 with his iconic supernatural    │
    │   │ "Deadman" persona, he became famous for his eerie presence, intricate storylines, and the legendary     │
    │   │ WrestleMania winning streak, which lasted for 21 matches. Known for his signature moves like the        │
    │   │ Tombstone Piledriver and the Chokeslam, The Undertaker's career spanned over three decades, during      │
    │   │ which he won multiple championships and captivated fans with his dark, enigmatic character and          │
    │   │ unparalleled in-ring prowess.                                                                           │
    │ 8 │ Bret Hart, also known as "The Hitman," is a retired Canadian professional wrestler, writer, and actor.  │
    │   │ Born on July 2, 1957, he is widely regarded as one of the greatest professional wrestlers of all time.  │
    │   │ He gained fame for his technical wrestling prowess, charismatic persona, and signature pink and black   │
    │   │ ring attire. Hart achieved significant success in the 1980s and 1990s, most notably in WWE (formerly    │
    │   │ WWF), where he held multiple world championships. He is also known for his tenure in WCW and for being  │
    │   │ part of the legendary Hart wrestling family. One of his most famous feuds involved the "Montreal        │
    │   │ Screwjob" incident in 1997. Beyond wrestling, Hart has authored books, appeared in films, and           │
    │   │ occasionally makes appearances in wrestling-related events.                                             │
    │ 9 │ "Macho Man" Randy Savage, born Randy Mario Poffo, was a professional wrestler and iconic figure in the  │
    │   │ world of sports entertainment. Known for his flamboyant attire, raspy voice, and intense charisma,      │
    │   │ Savage became one of the most recognizable and celebrated wrestlers of the 1980s and 1990s. He rose to  │
    │   │ fame in promotions like WWE (then WWF) and WCW, capturing multiple championships and headlining         │
    │   │ numerous major events. His signature catchphrase, "Ooh yeah!" and his memorable feuds with fellow       │
    │   │ wrestlers, including Hulk Hogan and Ricky "The Dragon" Steamboat, solidified his legacy as one of the   │
    │   │ all-time greats in professional wrestling. Additionally, Savage was a skilled in-ring performer, known  │
    │   │ for his athleticism and high-flying moves, most notably his diving elbow drop.                          │
    ╰───┴─────────────────────────────────────────────────────────────────────────────────────────────────────────╯